Skip to content

Commit

Permalink
Merge pull request PolkaGate#1389 from PolkaGate/assetUpdate
Browse files Browse the repository at this point in the history
fix asset update issue
  • Loading branch information
Nick-1979 authored Jun 25, 2024
2 parents cb9f200 + 8c54127 commit 1e7cc47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function TotalChart({ accountAssets, pricesInCurrency }: Props):
return () => {
chartInstance.destroy();
};
}, [assets, theme.palette.divider]);
}, [assets?.length, theme.palette.divider]);

return (
<Grid alignItems='center' container direction='column' item justifyContent='center' sx={{ bgcolor: 'background.paper', borderRadius: '5px', boxShadow: '2px 3px 4px 0px rgba(0, 0, 0, 0.1)', maxHeight: '185px', p: '15px', width: 'inherit' }}>
Expand Down
12 changes: 7 additions & 5 deletions packages/extension-ui/src/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,22 @@ export default function Popup(): React.ReactElement {
}, []);

useEffect(() => {
assetsOnChains && setAccountsAssets(assetsOnChains);
}, [assetsOnChains]);
assetsOnChains && setAccountsAssets({...assetsOnChains});
}, [assetsOnChains?.timeStamp]);

useEffect(() => {
/** remove forgotten accounts from assetChains if any */
if (accounts && assetsOnChains?.balances) {
Object.keys(assetsOnChains.balances).forEach((_address) => {
const found = accounts.find(({ address }) => address === _address);

!found && delete assetsOnChains.balances[_address];
setStorage(ASSETS_NAME_IN_STORAGE, assetsOnChains, true).catch(console.error);
if (!found) {
delete assetsOnChains.balances[_address];
setStorage(ASSETS_NAME_IN_STORAGE, assetsOnChains, true).catch(console.error);
}
});
}
}, [accounts, assetsOnChains]);
}, [accounts?.length, assetsOnChains?.timeStamp]);

useEffect(() => {
if (priceIds && currency?.code && !isFetchingPricesRef.current) {
Expand Down

0 comments on commit 1e7cc47

Please sign in to comment.