UNPKG

nostr-hooks

Version:
25 lines 745 B
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