diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-10 02:59:08 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-10 02:59:08 +0300 |
| commit | 894a506382b18748e889fec69028da9897555446 (patch) | |
| tree | 920a9158abecfb2ad4fc6294c4d86a2218506f36 /src/modules/serverSideStorage.js | |
| parent | 2c0eb29b286edf57d75c6044855ea5be9187493b (diff) | |
fixes
Diffstat (limited to 'src/modules/serverSideStorage.js')
| -rw-r--r-- | src/modules/serverSideStorage.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/modules/serverSideStorage.js b/src/modules/serverSideStorage.js index bb647b97..1a7e02b3 100644 --- a/src/modules/serverSideStorage.js +++ b/src/modules/serverSideStorage.js @@ -88,6 +88,8 @@ export const _getAllFlags = (recent, stale) => { } export const _mergeFlags = (recent, stale, allFlagKeys) => { + if (!stale.flagStorage) return recent.flagStorage + if (!recent.flagStorage) return stale.flagStorage return Object.fromEntries(allFlagKeys.map(flag => { const recentFlag = recent.flagStorage[flag] const staleFlag = stale.flagStorage[flag] @@ -113,7 +115,10 @@ export const _mergePrefs = (recent, stale, allFlagKeys) => { */ const resultOutput = { ...recentData } const totalJournal = uniqBy( - [...recentJournal, ...staleJournal].sort((a, b) => a.timestamp > b.timestamp ? -1 : 1), + [ + ...(Array.isArray(recentJournal) ? recentJournal : []), + ...(Array.isArray(staleJournal) ? staleJournal : []) + ].sort((a, b) => a.timestamp > b.timestamp ? -1 : 1), 'path' ).reverse() totalJournal.forEach(({ path, timestamp, operation, args }) => { @@ -243,6 +248,7 @@ export const mutations = { state.cache._timestamp = Math.min(stale._timestamp, recent._timestamp) } state.flagStorage = state.cache.flagStorage + state.prefsStorage = state.cache.prefsStorage }, setFlag (state, { flag, value }) { state.flagStorage[flag] = value |
