From 3b4bf9aa29b337aa07e0aba9d06e89116482499c Mon Sep 17 00:00:00 2001 From: enes Date: Mon, 14 Oct 2024 11:58:52 +0200 Subject: [PATCH] fix: only send to next signer on create --- src/pages/create/index.tsx | 39 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index de263e6..40da254 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -716,31 +716,28 @@ export const CreatePage = () => { toast.error('Failed to publish notifications') }) + // Send DM to the next signer setLoadingSpinnerDesc('Sending DMs') - // Send DM to signers and viewers - // No need to send notification to self so remove it from the list - const receivers = ( - signers.length > 0 - ? [signers[0].pubkey] - : viewers.map((viewer) => viewer.pubkey) - ).filter((receiver) => receiver !== usersPubkey) + if (signers.length > 0 && signers[0].pubkey !== usersPubkey) { + // No need to send notification to self so remove it from the list + const nextSigner = signers[0].pubkey - for (let i = 0; i < receivers.length; i++) { - const createSignatureEvent = await parseNostrEvent( - meta.createSignature - ) - const { id } = createSignatureEvent - const r = receivers[i] - try { - await sendPrivateDirectMessage( - `Sigit created, visit ${window.location.origin}/#/${signers.length > 0 ? 'sign' : 'verify'}/${id}`, - npubToHex(r!)! + if (nextSigner) { + const createSignatureEvent = await parseNostrEvent( + meta.createSignature ) - } catch (error) { - if (error instanceof SendDMError) { - toast.error(error.message) + const { id } = createSignatureEvent + try { + await sendPrivateDirectMessage( + `Sigit created, visit ${window.location.origin}/#/sign/${id}`, + npubToHex(nextSigner)! + ) + } catch (error) { + if (error instanceof SendDMError) { + toast.error(error.message) + } + console.error(error) } - console.error(error) } }