From f2f59d52cb9e7f4911596cace79263b1ec870f7b Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:19:28 -0800 Subject: [PATCH] feat: update legacy redux migration post X rollout (#7572) --- src/state/migrations.test.ts | 7 ++++++- src/state/migrations/legacy.ts | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/state/migrations.test.ts b/src/state/migrations.test.ts index 55470d5b28..070665a1f7 100644 --- a/src/state/migrations.test.ts +++ b/src/state/migrations.test.ts @@ -3,6 +3,7 @@ import { persistStore } from 'redux-persist' import { createDefaultStore } from 'state' import { initialState as initialListsState } from './lists/reducer' +import { RouterPreference } from './routing/types' import { initialState as initialSignaturesState } from './signatures/reducer' import { initialState as initialTransactionsState } from './transactions/reducer' import { initialState as initialUserState } from './user/reducer' @@ -70,7 +71,10 @@ describe('redux migrations', () => { 'redux_localstorage_simple_transactions', JSON.stringify({ 1: { test: { info: 'transactions' } } }) ) - localStorage.setItem('redux_localstorage_simple_user', JSON.stringify({ test: 'user' })) + localStorage.setItem( + 'redux_localstorage_simple_user', + JSON.stringify({ test: 'user', userRouterPreference: 'auto' }) + ) localStorage.setItem('redux_localstorage_simple_lists', JSON.stringify({ test: 'lists' })) localStorage.setItem('redux_localstorage_simple_signatures', JSON.stringify({ test: 'signatures' })) @@ -97,6 +101,7 @@ describe('redux migrations', () => { }, user: { test: 'user', + userRouterPreference: RouterPreference.X, }, signatures: { test: 'signatures', diff --git a/src/state/migrations/legacy.ts b/src/state/migrations/legacy.ts index 3ab592064d..85cad11658 100644 --- a/src/state/migrations/legacy.ts +++ b/src/state/migrations/legacy.ts @@ -108,12 +108,12 @@ function legacyUserMigrations(state: any): UserState { // If `userRouterPreference` is not present, reset to default if (typeof result.userRouterPreference !== 'string') { - result.userRouterPreference = RouterPreference.API + result.userRouterPreference = RouterPreference.X } - // If `userRouterPreference` is `AUTO`, migrate to `API` + // If `userRouterPreference` is `AUTO`, migrate to `X` if ((result.userRouterPreference as string) === 'auto') { - result.userRouterPreference = RouterPreference.API + result.userRouterPreference = RouterPreference.X } //If `buyFiatFlowCompleted` is present, delete it using filtering