feat: update legacy redux migration post X rollout (#7572)

This commit is contained in:
eddie 2023-11-13 15:19:28 -08:00 committed by GitHub
parent a5034cb1c0
commit f2f59d52cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

@ -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',

@ -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