redux-localstorage-simple
Advanced tools
Comparing version 2.1.5 to 2.1.6
@@ -78,3 +78,5 @@ 'use strict'; | ||
function lensPath(path, obj) { | ||
if (path.length === 1) { | ||
if (obj === undefined) { | ||
return null; | ||
} else if (path.length === 1) { | ||
return obj[path[0]]; | ||
@@ -240,3 +242,9 @@ } else { | ||
states.forEach(function (state) { | ||
localStorage[namespace + '_' + state] = JSON.stringify(getStateForLocalStorage(state, store.getState())); | ||
var stateForLocalStorage = getStateForLocalStorage(state, store.getState()); | ||
if (stateForLocalStorage) { | ||
localStorage[namespace + '_' + state] = JSON.stringify(stateForLocalStorage); | ||
} else { | ||
// Make sure nothing is ever saved for this incorrect state | ||
localStorage.removeItem(namespace + '_' + state); | ||
} | ||
}); | ||
@@ -328,3 +336,3 @@ } | ||
states.forEach(function (state) { | ||
if (localStorage[namespace + '_' + state] !== 'undefined') { | ||
if (localStorage.getItem(namespace + '_' + state)) { | ||
loadedState = (0, _objectMerge2.default)(loadedState, realiseObject(state, JSON.parse(localStorage[namespace + '_' + state]))); | ||
@@ -331,0 +339,0 @@ } else { |
{ | ||
"name": "redux-localstorage-simple", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "Save and load Redux state to and from LocalStorage.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -61,3 +61,5 @@ 'use strict' | ||
function lensPath (path, obj) { | ||
if (path.length === 1) { | ||
if (obj === undefined) { | ||
return null | ||
} else if (path.length === 1) { | ||
return obj[path[0]] | ||
@@ -214,4 +216,10 @@ } else { | ||
} else { | ||
states.forEach(state => { | ||
localStorage[namespace + '_' + state] = JSON.stringify(getStateForLocalStorage(state, store.getState())) | ||
states.forEach(state => { | ||
const stateForLocalStorage = getStateForLocalStorage(state, store.getState()) | ||
if (stateForLocalStorage) { | ||
localStorage[namespace + '_' + state] = JSON.stringify(stateForLocalStorage) | ||
} else { | ||
// Make sure nothing is ever saved for this incorrect state | ||
localStorage.removeItem(namespace + '_' + state) | ||
} | ||
}) | ||
@@ -294,3 +302,3 @@ } | ||
states.forEach(function (state) { | ||
if (localStorage[namespace + '_' + state] !== 'undefined') { | ||
if (localStorage.getItem(namespace + '_' + state)) { | ||
loadedState = objectMerge(loadedState, realiseObject(state, JSON.parse(localStorage[namespace + '_' + state]))) | ||
@@ -297,0 +305,0 @@ } else { |
Sorry, the diff of this file is too big to display
135077
3088