Skip to content

Commit

Permalink
fix: 🐛 fix a delay on the account toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoscurati committed Jun 19, 2024
1 parent f5a3437 commit f5b7ca7
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect, useState, useCallback, useContext } from 'react';
import { useSelector } from 'react-redux';
import { MetaMetricsContext } from '../../contexts/metametrics';
import {
MetaMetricsEventCategory,
Expand All @@ -15,7 +14,6 @@ import {
NotificationsSettingsBox,
NotificationsSettingsAccount,
} from '../../components/multichain';
import { getIsUpdatingMetamaskNotificationsAccount } from '../../selectors/metamask-notifications/metamask-notifications';

type NotificationsSettingsPerAccountProps = {
address: string;
Expand Down Expand Up @@ -46,11 +44,6 @@ export const NotificationsSettingsPerAccount = ({
>(undefined);
const [isLoading, setIsLoading] = useState<boolean>(false);

// Selectors
const isUpdatingMetamaskNotificationsAccount = useSelector(
getIsUpdatingMetamaskNotificationsAccount,
);

useEffect(() => {
const fetchData = async () => {
const fetchedData = await switchAccountNotifications([address]);
Expand All @@ -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;

Expand All @@ -88,6 +71,8 @@ export const NotificationsSettingsPerAccount = ({
address,
},
});
const fetchedData = await switchAccountNotifications([address]);
setData(fetchedData || {});
listNotifications();
}, [address, data, onChangeAccountNotifications]);

Expand Down

0 comments on commit f5b7ca7

Please sign in to comment.