fix settings not persisting

This commit is contained in:
Henry Jameson 2022-03-17 09:02:26 +02:00
parent d815f984fb
commit a97c07bfdf

View File

@ -1,6 +1,6 @@
import merge from 'lodash.merge' import merge from 'lodash.merge'
import localforage from 'localforage' import localforage from 'localforage'
import { each, get, set } from 'lodash' import { each, get, set, cloneDeep } from 'lodash'
let loaded = false let loaded = false
@ -69,7 +69,7 @@ export default function createPersistedState ({
subscriber(store)((mutation, state) => { subscriber(store)((mutation, state) => {
try { try {
if (saveImmedeatelyActions.includes(mutation.type)) { if (saveImmedeatelyActions.includes(mutation.type)) {
setState(key, reducer(state, paths), storage) setState(key, reducer(cloneDeep(state), paths), storage)
.then(success => { .then(success => {
if (typeof success !== 'undefined') { if (typeof success !== 'undefined') {
if (mutation.type === 'setOption' || mutation.type === 'setCurrentUser') { if (mutation.type === 'setOption' || mutation.type === 'setCurrentUser') {