From 894a506382b18748e889fec69028da9897555446 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 10 Aug 2022 02:59:08 +0300 Subject: [PATCH] fixes --- src/modules/serverSideStorage.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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