@@ -6,6 +6,9 @@ import { get as getFromDb, set as setToDb } from 'idb-keyval'
6
6
import config from '../../../../config'
7
7
import { RootState } from '../../'
8
8
9
+
10
+ const EXPANSIONS_DB_KEY = 'expansions'
11
+
9
12
///////////
10
13
// STATE //
11
14
///////////
@@ -64,7 +67,7 @@ export const Reducer: LoopReducer<State, Action> = (
64
67
return loop (
65
68
newState ,
66
69
Cmd . run < Action > ( setToDb , {
67
- args : [ 'sets' , newState ] ,
70
+ args : [ EXPANSIONS_DB_KEY , newState ] ,
68
71
successActionCreator : actions . setToDBSuccessful ,
69
72
failActionCreator : actions . setToDBFailed ,
70
73
} )
@@ -76,7 +79,7 @@ export const Reducer: LoopReducer<State, Action> = (
76
79
return loop (
77
80
newState ,
78
81
Cmd . run < Action > ( setToDb , {
79
- args : [ 'sets' , newState ] ,
82
+ args : [ EXPANSIONS_DB_KEY , newState ] ,
80
83
successActionCreator : actions . setToDBSuccessful ,
81
84
failActionCreator : actions . setToDBFailed ,
82
85
} )
@@ -87,15 +90,19 @@ export const Reducer: LoopReducer<State, Action> = (
87
90
return loop (
88
91
state ,
89
92
Cmd . run < Action > ( getFromDb , {
93
+ args : [ EXPANSIONS_DB_KEY ] ,
90
94
successActionCreator : actions . fetchFromDBSuccessful ,
91
95
failActionCreator : actions . fetchFromDBFailed ,
92
- args : [ 'sets' ]
93
96
} )
94
97
)
95
98
}
96
99
97
100
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
99
106
}
100
107
101
108
default : {
0 commit comments