From 9cefdad3fce093758c511e2f4d8b8f9fee3fe7b4 Mon Sep 17 00:00:00 2001 From: Eugene Date: Fri, 30 Aug 2024 17:11:56 +0300 Subject: [PATCH] refactor: logs npubs for failed notifications --- src/pages/create/index.tsx | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index 29bca5e..e51a9d9 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -788,24 +788,13 @@ export const CreatePage = () => { setLoadingSpinnerDesc('Sending notifications to counterparties') const notifications = await Promise.allSettled(sendNotifications(meta)) if (notifications.every(isPromiseFulfilled)) { - toast.success('finished processing notifications!') + toast.success('Notifications sent successfully') } else { - notifications - .filter(isPromiseRejected) - .map((res: PromiseRejectedResult) => res.reason) - .forEach((res) => console.log('rejected result: ', res)) + logRejectedNotifications(notifications) + toast.error( + 'Some notifications failed to publish. Please rebroadcast them again.' + ) } - - // const promises = sendNotifications(meta) - - // await Promise.all(promises) - // .then(() => { - // toast.success('Notifications sent successfully') - // }) - // .catch(() => { - // toast.error('Failed to publish notifications') - // }) - navigate(appPrivateRoutes.sign, { state: { meta: meta } }) } else { const zip = new JSZip() @@ -861,6 +850,15 @@ export const CreatePage = () => { } } + const logRejectedNotifications = ( + notifications: PromiseSettledResult[] + ) => { + notifications + .filter(isPromiseRejected) + .map((res: PromiseRejectedResult) => (res.reason as Error).message) + .forEach((message: string) => console.log(message)) + } + const onDrawFieldsChange = (sigitFiles: SigitFile[]) => { setDrawnFiles(sigitFiles) }