From 87359a914e4c6aaf6198a0e00be76c707e27e9ab Mon Sep 17 00:00:00 2001 From: daniyal Date: Thu, 5 Sep 2024 15:16:42 +0500 Subject: [PATCH] fix: add signed event to reactionEvents array even before publishing so that UI can be updated immediately --- src/pages/mod.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/mod.tsx b/src/pages/mod.tsx index dbe1bbe..cd27bf3 100644 --- a/src/pages/mod.tsx +++ b/src/pages/mod.tsx @@ -1882,13 +1882,15 @@ const Reactions = ({ modDetails }: ReactionsProps) => { ?.signEvent(unsignedEvent) .then((event) => event as Event) .catch((err) => { - toast.error('Failed to sign the event!') + toast.error('Failed to sign the reaction event!') log(true, LogType.Error, 'Failed to sign the event!', err) return null }) if (!signedEvent) return + setReactionEvents((prev) => [...prev, signedEvent]) + const publishedOnRelays = await RelayController.getInstance().publish( signedEvent as Event, modDetails.author, @@ -1896,11 +1898,13 @@ const Reactions = ({ modDetails }: ReactionsProps) => { ) if (publishedOnRelays.length === 0) { - toast.error('Failed to publish reaction event on any relay') + log( + true, + LogType.Error, + 'Failed to publish reaction event on any relay' + ) return } - - setReactionEvents((prev) => [...prev, signedEvent]) } finally { setIsReactionInProgress(false) }