Skip to content

Commit df546f1

Browse files
authored
changed to use restoreState instead of reducer as this will reduce on the data that is onLoad instead of onSave. (#377)
1 parent 697c9ba commit df546f1

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

client/containers/domain-autocomplete/reducer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
import { migrateRecentDomains } from './helpers';
2323

2424
const reducer = state => ({
25-
...state.domainAutocomplete,
26-
visitedDomainList: migrateRecentDomains(
27-
state.domainAutocomplete.visitedDomainList
28-
),
25+
...state,
26+
visitedDomainList: migrateRecentDomains(state.visitedDomainList),
2927
});
3028

3129
export default reducer;

client/store/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,18 @@ const getStoreConfig = ({ router, state }) => {
8585
const initialState = getDefaultState(state);
8686

8787
const vuexLocal = new VuexPersistence({
88-
reducer: state => ({
89-
...state,
90-
domainAutocomplete: domainAutocompleteReducer(state),
91-
}),
88+
restoreState: key => {
89+
const state = JSON.tryParse(localStorage.getItem(key));
90+
91+
if (!state) {
92+
return;
93+
}
94+
95+
return {
96+
...state,
97+
domainAutocomplete: domainAutocompleteReducer(state.domainAutocomplete),
98+
};
99+
},
92100
storage: window.localStorage,
93101
});
94102

0 commit comments

Comments
 (0)