From f5b7ca799b5ab9fe016b56c004584108cbfef186 Mon Sep 17 00:00:00 2001 From: Matteo Scurati Date: Wed, 19 Jun 2024 18:34:21 +0200 Subject: [PATCH] fix: :bug: fix a delay on the account toggles --- .../notifications-settings-per-account.tsx | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/ui/pages/notifications-settings/notifications-settings-per-account.tsx b/ui/pages/notifications-settings/notifications-settings-per-account.tsx index 337a8af96582..a591a4f81ea9 100644 --- a/ui/pages/notifications-settings/notifications-settings-per-account.tsx +++ b/ui/pages/notifications-settings/notifications-settings-per-account.tsx @@ -1,5 +1,4 @@ import React, { useEffect, useState, useCallback, useContext } from 'react'; -import { useSelector } from 'react-redux'; import { MetaMetricsContext } from '../../contexts/metametrics'; import { MetaMetricsEventCategory, @@ -15,7 +14,6 @@ import { NotificationsSettingsBox, NotificationsSettingsAccount, } from '../../components/multichain'; -import { getIsUpdatingMetamaskNotificationsAccount } from '../../selectors/metamask-notifications/metamask-notifications'; type NotificationsSettingsPerAccountProps = { address: string; @@ -46,11 +44,6 @@ export const NotificationsSettingsPerAccount = ({ >(undefined); const [isLoading, setIsLoading] = useState(false); - // Selectors - const isUpdatingMetamaskNotificationsAccount = useSelector( - getIsUpdatingMetamaskNotificationsAccount, - ); - useEffect(() => { const fetchData = async () => { const fetchedData = await switchAccountNotifications([address]); @@ -63,16 +56,6 @@ export const NotificationsSettingsPerAccount = ({ setIsLoading(loading); }, [loading]); - useEffect(() => { - const updateData = async () => { - if (isUpdatingMetamaskNotificationsAccount.includes(address)) { - const fetchedData = await switchAccountNotifications([address]); - setData(fetchedData || {}); - } - }; - updateData(); - }, [isUpdatingMetamaskNotificationsAccount]); - const error = errorAccountNotificationsChange || errorSwitchAccountNotifications; @@ -88,6 +71,8 @@ export const NotificationsSettingsPerAccount = ({ address, }, }); + const fetchedData = await switchAccountNotifications([address]); + setData(fetchedData || {}); listNotifications(); }, [address, data, onChangeAccountNotifications]);