Skip to content

Commit 95bdaa7

Browse files
authored
fix: persist quick account dismiss only during session (#1851)
- Closes #1782 - Closes FE-1330 # Summary Turn off quick connect persistent cache. Now it's session based. # Checklist - [X] I've added error handling for all actions/requests, and verified how this error will show on UI. (or there was no error handling) - [X] I've reviewed all the copy changed/added in this PR, using AI if needed. (or there was no copy changes) - [X] I've included the reference to the issues being closed from Github and/or Linear (or there was no issues) - [X] I've changed the Docs to reflect my changes (or it was not needed) - [X] I've put docs links where it may be helpful (or it was not needed) - [X] I checked the resulting UI both in Light and Dark mode (or no UI changes were made) - [X] I **reviewed** the **entire PR** myself (preferably, on GH UI)
1 parent 2336981 commit 95bdaa7

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

.changeset/popular-mails-argue.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/app/src/systems/Account/components/QuickAccountConnect/QuickAccountConnect.tsx

+9-19
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
VStack,
1010
toast,
1111
} from '@fuel-ui/react';
12-
import { useEffect, useMemo, useState } from 'react';
12+
import { useMemo, useState } from 'react';
1313
import { useCurrentTab } from '~/systems/CRX/hooks/useCurrentTab';
1414
import { useConnection } from '~/systems/DApp/hooks/useConnection';
1515
import { useOrigin } from '~/systems/DApp/hooks/useOrigin';
@@ -22,10 +22,6 @@ enum ConnectionStatus {
2222
NoAccounts = 'NO_ACCOUNTS',
2323
}
2424

25-
export const getDismissKey = (account: string, origin: string) => {
26-
return `quick-account-connect-${account}-${origin}`;
27-
};
28-
2925
export const QuickAccountConnect = () => {
3026
const { account } = useCurrentAccount();
3127
const { currentTab } = useCurrentTab();
@@ -34,7 +30,7 @@ export const QuickAccountConnect = () => {
3430
origin: origin?.full,
3531
});
3632

37-
const [dismissed, setDismissed] = useState(true);
33+
const [dismissedAccount, setDismissedAccount] = useState<string>('');
3834

3935
const status = useMemo<ConnectionStatus>(() => {
4036
if (!account || !connection) {
@@ -48,6 +44,10 @@ export const QuickAccountConnect = () => {
4844
return ConnectionStatus.OtherAccount;
4945
}, [account, connection]);
5046

47+
const isDismissed = useMemo<boolean>(() => {
48+
return account?.address === dismissedAccount;
49+
}, [account?.address, dismissedAccount]);
50+
5151
const onConnect = async () => {
5252
if (!origin || !account) return;
5353
await ConnectionService.addAccountTo({
@@ -59,25 +59,15 @@ export const QuickAccountConnect = () => {
5959
};
6060

6161
const onDismiss = () => {
62-
if (!origin || !account) return;
63-
setDismissed(true);
64-
if (typeof localStorage !== 'undefined') {
65-
localStorage.setItem(getDismissKey(account.address, origin.full), 'true');
62+
if (account?.address) {
63+
setDismissedAccount(account.address);
6664
}
6765
};
6866

69-
useEffect(() => {
70-
if (!origin || !account) return;
71-
const hasDismissed = localStorage.getItem(
72-
getDismissKey(account.address, origin.full)
73-
);
74-
setDismissed(!!hasDismissed);
75-
}, [account, origin]);
76-
7767
return (
7868
<Box
7969
css={styles.wrapper}
80-
data-open={status === ConnectionStatus.OtherAccount && !dismissed}
70+
data-open={status === ConnectionStatus.OtherAccount && !isDismissed}
8171
>
8272
<Alert status="info" css={styles.alert}>
8373
<Alert.Description as="div">

0 commit comments

Comments
 (0)