aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/local_storage
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-12-14 09:58:33 +0800
committerFabio Berger <me@fabioberger.com>2017-12-14 09:58:33 +0800
commit105bcc6664f0d4ab642486977f1edaf8d84b020e (patch)
tree4e2deb2f1c54018b1fadfe91ed6a661cd4198014 /packages/website/ts/local_storage
parentceae51fe322ebf444d0c8b61fdb7a86ab11c8071 (diff)
downloaddexon-sol-tools-105bcc6664f0d4ab642486977f1edaf8d84b020e.tar.gz
dexon-sol-tools-105bcc6664f0d4ab642486977f1edaf8d84b020e.tar.zst
dexon-sol-tools-105bcc6664f0d4ab642486977f1edaf8d84b020e.zip
Clear trackedTokens so that a user starts tracking the new WETH and no longer the old one
Diffstat (limited to 'packages/website/ts/local_storage')
-rw-r--r--packages/website/ts/local_storage/tracked_token_storage.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/website/ts/local_storage/tracked_token_storage.ts b/packages/website/ts/local_storage/tracked_token_storage.ts
index 051a78ae1..086b06af5 100644
--- a/packages/website/ts/local_storage/tracked_token_storage.ts
+++ b/packages/website/ts/local_storage/tracked_token_storage.ts
@@ -1,10 +1,21 @@
import * as _ from 'lodash';
import {localStorage} from 'ts/local_storage/local_storage';
import {Token, TrackedTokensByNetworkId} from 'ts/types';
+import {configs} from 'ts/utils/configs';
const TRACKED_TOKENS_KEY = 'trackedTokens';
+const TRACKED_TOKENS_CLEAR_KEY = 'lastClearTrackedTokensDate';
export const trackedTokenStorage = {
+ // Clear trackedTokens localStorage if we've updated the config variable in an update
+ // that introduced a backward incompatible change requiring the tracked tokens to be re-set
+ clearIfRequired() {
+ const lastClearFillDate = localStorage.getItemIfExists(TRACKED_TOKENS_CLEAR_KEY);
+ if (lastClearFillDate !== configs.lastLocalStorageTrackedTokenClearanceDate) {
+ localStorage.removeItem(TRACKED_TOKENS_KEY);
+ }
+ localStorage.setItem(TRACKED_TOKENS_CLEAR_KEY, configs.lastLocalStorageTrackedTokenClearanceDate);
+ },
addTrackedTokenToUser(userAddress: string, networkId: number, token: Token) {
const trackedTokensByUserAddress = this.getTrackedTokensByUserAddress();
let trackedTokensByNetworkId = trackedTokensByUserAddress[userAddress];