From b04f4fb88d139cdd4050d56d592e41b79ae79a72 Mon Sep 17 00:00:00 2001 From: enes Date: Mon, 14 Oct 2024 13:19:44 +0200 Subject: [PATCH] refactor: show sent dm count, don't sent twice to creator --- src/pages/sign/index.tsx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/pages/sign/index.tsx b/src/pages/sign/index.tsx index be64a67..ed925e1 100644 --- a/src/pages/sign/index.tsx +++ b/src/pages/sign/index.tsx @@ -744,6 +744,12 @@ export const SignPage = () => { console.error(error) } } + + if (areSent.some((r) => r)) { + toast.success( + `DMs sent ${areSent.filter((r) => r).length}/${users.length}` + ) + } } else { // Notify the creator and the next signer (/sign). try { @@ -758,18 +764,21 @@ export const SignPage = () => { console.error(error) } - try { - const currentSignerIndex = signers.indexOf(usersNpub) - const nextSigner = signers[currentSignerIndex + 1] - await sendPrivateDirectMessage( - `You're the next signer, visit ${window.location.origin}/#/sign/${id}`, - npubToHex(nextSigner)! - ) - } catch (error) { - if (error instanceof SendDMError) { - toast.error(error.message) + // No need to notify creator twice, skipping + const currentSignerIndex = signers.indexOf(usersNpub) + const nextSigner = signers[currentSignerIndex + 1] + if (nextSigner !== submittedBy) { + try { + await sendPrivateDirectMessage( + `You're the next signer, visit ${window.location.origin}/#/sign/${id}`, + npubToHex(nextSigner)! + ) + } catch (error) { + if (error instanceof SendDMError) { + toast.error(error.message) + } + console.error(error) } - console.error(error) } }