Skip to content

Commit

Permalink
fix: notification enable disable when frequent wallet user change (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
imvinay84 authored Mar 24, 2023
1 parent a3d576c commit e3db6cb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/extension/src/layouts/bottom-nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,16 @@ const NotificationTab = () => {
const accountInfo = accountStore.getAccount(current.chainId);
const config: WalletConfig = useSelector(walletConfig);
const notificationInfo: NotificationSetup = useSelector(notificationsDetails);
const [isComingSoon, setIsComingSoon] = useState<boolean>(true);

useEffect(() => {
setIsComingSoon(
config.notiphyWhitelist === undefined
? true
: config.notiphyWhitelist.length !== 0 &&
config.notiphyWhitelist.indexOf(accountInfo.bech32Address) === -1
);

const notificationFlag =
localStorage.getItem(`turnNotifications-${accountInfo.bech32Address}`) ||
"true";
Expand All @@ -75,27 +83,19 @@ const NotificationTab = () => {
isNotificationOn: notificationFlag == "true",
})
);
}, [accountInfo.bech32Address]);

const isComingSoon = () => {
return (
config.notiphyWhitelist !== undefined &&
config.notiphyWhitelist.length !== 0 &&
config.notiphyWhitelist.indexOf(accountInfo.bech32Address) === -1
);
};
}, [accountInfo.bech32Address, config.notiphyWhitelist]);

return (
<>
{!isComingSoon() &&
{!isComingSoon &&
notificationInfo.unreadNotification &&
notificationInfo.isNotificationOn && <span className={style.bellDot} />}
<Tab
title={"Notification"}
icon={bellOnGreyIcon}
activeTabIcon={bellOnBlueIcon}
path={"/notification"}
disabled={isComingSoon()}
disabled={isComingSoon}
tooltip={"Coming Soon"}
/>
</>
Expand Down

0 comments on commit e3db6cb

Please sign in to comment.