nostr-hooks
Version:
React hooks for developing Nostr clients
25 lines • 745 B
JavaScript
import { NDKEvent, NDKRelaySet } from '@nostr-dev-kit/ndk';
import { useStore } from '../../../../store';
export const sendGroupChat = ({ relay, groupId, chat, onSuccess, onError, }) => {
const ndk = useStore.getState().ndk;
if (!ndk)
return;
if (!groupId)
return;
const event = new NDKEvent(ndk);
event.kind = 9;
event.content = chat.content;
event.tags = [['h', groupId]];
chat.parentId && event.tags.push(['q', chat.parentId]);
event.publish(NDKRelaySet.fromRelayUrls([relay], ndk)).then((r) => {
if (r.size > 0) {
onSuccess?.();
}
else {
onError?.();
}
}, () => {
onError?.();
});
};
//# sourceMappingURL=index.js.map