Skip to content

Commit

Permalink
refactor: only update active account on polling
Browse files Browse the repository at this point in the history
  • Loading branch information
kieranroneill committed Sep 19, 2024
1 parent 58db023 commit eaee839
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
12 changes: 11 additions & 1 deletion src/extension/components/SideBar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ import {
import { AccountTabEnum } from '@extension/enums';

// features
import { saveActiveAccountDetails } from '@extension/features/accounts';
import {
saveActiveAccountDetails,
updateAccountsThunk,
} from '@extension/features/accounts';
import { setScanQRCodeModal } from '@extension/features/layout';
import { initialize as initializeSendAssets } from '@extension/features/send-assets';

Expand Down Expand Up @@ -106,6 +109,13 @@ const SideBar: FC = () => {
tabIndex: activeAccountDetails?.tabIndex || AccountTabEnum.Assets,
})
);
dispatch(
updateAccountsThunk({
accountIDs: [id],
notifyOnNewTransactions: true,
refreshTransactions: true,
})
);
navigate(`${ACCOUNTS_ROUTE}`, {
replace: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ const startPollingForAccountsThunk: AsyncThunk<
);

return window.setInterval(() => {
const accounts = getState().accounts.items;

dispatch(
updateAccountsThunk({
accountIDs: accounts.map(({ id }) => id),
notifyOnNewTransactions: true,
refreshTransactions: true, // get latest transactions
})
);
const activeAccountDetails = getState().accounts.activeAccountDetails;

if (activeAccountDetails) {
dispatch(
updateAccountsThunk({
accountIDs: [activeAccountDetails.accountId],
notifyOnNewTransactions: true,
refreshTransactions: true, // get latest transactions
})
);
}
}, ACCOUNT_INFORMATION_REFRESH_INTERVAL);
});

Expand Down

0 comments on commit eaee839

Please sign in to comment.