Skip to content

Commit

Permalink
CP-8042: fix app crashing due to invalid initial browser data (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
atn4z7 committed Jan 15, 2024
1 parent 07db803 commit 341a7c8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/core-mobile/app/store/browser/slices/favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { favoriteAdapter } from '../utils'

const reducerName = 'browser/favorites'

const initialState: FavoriteState = favoriteAdapter.getInitialState()
export const initialState: FavoriteState = favoriteAdapter.getInitialState()

const favoriteSlice = createSlice({
name: reducerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { addHistoryForActiveTab } from './tabs'

const reducerName = 'browser/globalHistory'

const initialState = historyAdapter.getInitialState()
export const initialState = historyAdapter.getInitialState()

const globalHistorySlice = createSlice({
name: reducerName,
Expand Down
2 changes: 1 addition & 1 deletion packages/core-mobile/app/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { AppBlacklistTransform } from './transforms/AppBlacklistTransform'
import { combinedReducer as browser } from './browser'
import { snapshotsReducer as snapshots } from './snapshots/slice'

const VERSION = 11
const VERSION = 10

// list of reducers that don't need to be persisted
// for nested/partial blacklist, please use transform
Expand Down
19 changes: 10 additions & 9 deletions packages/core-mobile/app/store/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
DefaultFeatureFlagConfig,
initialState as posthogInitialState
} from './posthog'

import { initialState as browserFavoritesInitialState } from './browser/slices/favorites'
import { getInitialState as browserTabsGetInitialState } from './browser/slices/tabs'
import { initialState as browserGlobalHistoryInitialState } from './browser/slices/globalHistory'
/* eslint-disable @typescript-eslint/no-explicit-any */
export const migrations = {
1: (state: any) => {
Expand Down Expand Up @@ -127,16 +129,15 @@ export const migrations = {
}
},
10: async (state: any) => {
//wipe browser state since this is first version that users are actually gonna use
return {
...state,
browser: undefined
}
},
11: async (state: any) => {
//set security countdown
return {
...state,
// reset browser data
browser: {
favorites: browserFavoritesInitialState,
globalHistory: browserGlobalHistoryInitialState,
tabs: browserTabsGetInitialState()
},
// set security countdown
security: {
loginAttempt: {
count: state.security.loginAttempt.count,
Expand Down

0 comments on commit 341a7c8

Please sign in to comment.