add and verify local storage version

fix: #131
pull/137/head
Szymon Lesisz 6 years ago
parent 33ba41e865
commit b9251f8db7

@ -88,6 +88,8 @@ export function update(event: StorageEvent): AsyncAction {
};
}
const VERSION: string = '1';
export function loadTokensFromJSON(): AsyncAction {
return async (dispatch: Dispatch): Promise<void> => {
if (typeof window.localStorage === 'undefined') return;
@ -100,6 +102,13 @@ export function loadTokensFromJSON(): AsyncAction {
dispatch(update(event));
});
// validate version
const version: ?string = get('version');
if (version !== VERSION) {
window.localStorage.clear();
dispatch(save('version', VERSION));
}
// load tokens
const tokens = await config.coins.reduce(async (promise: Promise<TokensCollection>, coin: Coin): Promise<TokensCollection> => {
const collection: TokensCollection = await promise;

Loading…
Cancel
Save