Merge pull request #3685 from urbit/ted/fix-local-storage-rehydrate

LocalReducer: fix empty case of localStorage rehydration
This commit is contained in:
matildepark 2020-10-08 18:02:38 -04:00 committed by GitHub
commit 8559d9d7de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ type LocalState = Pick<StoreState, 'sidebarShown' | 'omniboxShown' | 'baseHash'
export default class LocalReducer<S extends LocalState> {
rehydrate(state: S) {
try {
const json = JSON.parse(localStorage.getItem('localReducer') || '');
const json = JSON.parse(localStorage.getItem('localReducer') || '{}');
_.forIn(json, (value, key) => {
state[key] = value;
});