UNPKG

nostr-hooks

Version:
25 lines 760 B
import { NDKEvent, NDKRelaySet } from '@nostr-dev-kit/ndk'; import { useStore } from '../../../../store'; export const sendGroupThread = ({ relay, groupId, thread, onSuccess, onError, }) => { const ndk = useStore.getState().ndk; if (!ndk) return; if (!groupId) return; const event = new NDKEvent(ndk); event.kind = 11; event.content = thread.content; event.tags = [['h', groupId]]; thread.subject && event.tags.push(['subject', thread.subject]); event.publish(NDKRelaySet.fromRelayUrls([relay], ndk)).then((r) => { if (r.size > 0) { onSuccess?.(); } else { onError?.(); } }, () => { onError?.(); }); }; //# sourceMappingURL=index.js.map