From 060c6013f18dcd6fff3061717d3553610e227441 Mon Sep 17 00:00:00 2001 From: mpblocky <185767042+mpblocky@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:09:35 +0100 Subject: [PATCH] [Human App] fix: error notification is displayed twice when should be once (#3110) --- .../components/profile/profile.page.tsx | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/packages/apps/human-app/frontend/src/modules/worker/components/profile/profile.page.tsx b/packages/apps/human-app/frontend/src/modules/worker/components/profile/profile.page.tsx index 41425547d0..56eb56ff43 100644 --- a/packages/apps/human-app/frontend/src/modules/worker/components/profile/profile.page.tsx +++ b/packages/apps/human-app/frontend/src/modules/worker/components/profile/profile.page.tsx @@ -14,23 +14,34 @@ import { useAuthenticatedUser } from '@/modules/auth/hooks/use-authenticated-use export function WorkerProfilePage() { const { user } = useAuthenticatedUser(); const isMobile = useIsMobile(); - const { isConnected } = useWalletConnect(); + const { isConnected, initializing, web3ProviderMutation } = + useWalletConnect(); const { showNotification } = useNotification(); - const setNotifications = () => { - if (user.wallet_address) { - return; + useEffect(() => { + if (initializing) return; + + if (!isConnected || !user.wallet_address) { + showNotification({ + type: TopNotificationType.WARNING, + message: t('worker.profile.topNotifications.completeSteps'), + }); } - showNotification({ - type: TopNotificationType.WARNING, - message: t('worker.profile.topNotifications.completeSteps'), - }); - }; - useEffect(() => { - setNotifications(); - // eslint-disable-next-line react-hooks/exhaustive-deps -- call this once - }, [isConnected]); + if (web3ProviderMutation.isError && web3ProviderMutation.failureReason) { + showNotification({ + type: TopNotificationType.WARNING, + message: web3ProviderMutation.failureReason.message, + }); + } + }, [ + isConnected, + initializing, + web3ProviderMutation.failureReason, + web3ProviderMutation.isError, + user.wallet_address, + showNotification, + ]); return (