Skip to content

Commit dc25321

Browse files
committed
[HOTFIX] Fix major application crash
The crash was caused by missing data inside indexed db. Users without existing data, would not be able to start the app at all.
1 parent 2801a6b commit dc25321

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Redux/Store/Settings/Expansions/Selected.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { get as getFromDb, set as setToDb } from 'idb-keyval'
66
import config from '../../../../config'
77
import { RootState } from '../../'
88

9+
10+
const EXPANSIONS_DB_KEY = 'expansions'
11+
912
///////////
1013
// STATE //
1114
///////////
@@ -64,7 +67,7 @@ export const Reducer: LoopReducer<State, Action> = (
6467
return loop(
6568
newState,
6669
Cmd.run<Action>( setToDb, {
67-
args: ['sets', newState],
70+
args: [EXPANSIONS_DB_KEY, newState],
6871
successActionCreator: actions.setToDBSuccessful,
6972
failActionCreator: actions.setToDBFailed,
7073
})
@@ -76,7 +79,7 @@ export const Reducer: LoopReducer<State, Action> = (
7679
return loop(
7780
newState,
7881
Cmd.run<Action>( setToDb, {
79-
args: ['sets', newState],
82+
args: [EXPANSIONS_DB_KEY, newState],
8083
successActionCreator: actions.setToDBSuccessful,
8184
failActionCreator: actions.setToDBFailed,
8285
})
@@ -87,15 +90,19 @@ export const Reducer: LoopReducer<State, Action> = (
8790
return loop(
8891
state,
8992
Cmd.run<Action>( getFromDb, {
93+
args: [EXPANSIONS_DB_KEY],
9094
successActionCreator: actions.fetchFromDBSuccessful,
9195
failActionCreator: actions.fetchFromDBFailed,
92-
args: ['sets']
9396
})
9497
)
9598
}
9699

97100
case ActionTypes.FETCH_FROM_DB_SUCCESS: {
98-
return action.payload
101+
return action.payload || initialState
102+
}
103+
104+
case ActionTypes.FETCH_FROM_DB_FAILURE: {
105+
return state
99106
}
100107

101108
default: {

0 commit comments

Comments
 (0)