diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js --- a/lib/reducers/master-reducer.js +++ b/lib/reducers/master-reducer.js @@ -180,17 +180,21 @@ threadStoreOperations, ); - const { enabledApps } = reduceEnabledApps(state.enabledApps, action); + const { enabledApps, syncedMetadataStoreOperations: enabledAppsOps } = + reduceEnabledApps(state.enabledApps, action); - const { globalThemeInfo } = reduceGlobalThemeInfo( - state.globalThemeInfo, - action, - ); + const { globalThemeInfo, syncedMetadataStoreOperations: globalThemeInfoOps } = + reduceGlobalThemeInfo(state.globalThemeInfo, action); - const { alertStore } = reduceAlertStore(state.alertStore, action); + const { alertStore, syncedMetadataStoreOperations: alertStoreOps } = + reduceAlertStore(state.alertStore, action); const { syncedMetadataStore, syncedMetadataStoreOperations } = - reduceSyncedMetadataStore(state.syncedMetadataStore, action); + reduceSyncedMetadataStore(state.syncedMetadataStore, action, [ + ...enabledAppsOps, + ...globalThemeInfoOps, + ...alertStoreOps, + ]); const { auxUserStore, auxUserStoreOperations } = reduceAuxUserStore( state.auxUserStore, diff --git a/lib/reducers/synced-metadata-reducer.js b/lib/reducers/synced-metadata-reducer.js --- a/lib/reducers/synced-metadata-reducer.js +++ b/lib/reducers/synced-metadata-reducer.js @@ -20,6 +20,10 @@ function reduceSyncedMetadataStore( state: SyncedMetadataStore, action: BaseAction, + // IMPORTANT: always process and return predefinedStoreOperations, + // regardless of action type; the only exception + // is setClientDBStoreActionType + predefinedStoreOperations: $ReadOnlyArray, ): { +syncedMetadataStore: SyncedMetadataStore, +syncedMetadataStoreOperations: $ReadOnlyArray, @@ -30,9 +34,17 @@ payload: action.payload, }; + const syncedMetadataStoreOperations = [ + ...predefinedStoreOperations, + replaceOperation, + ]; + return { - syncedMetadataStore: processStoreOps(state, [replaceOperation]), - syncedMetadataStoreOperations: [replaceOperation], + syncedMetadataStore: processStoreOps( + state, + syncedMetadataStoreOperations, + ), + syncedMetadataStoreOperations, }; } else if (action.type === clearSyncedMetadataEntryActionType) { const removeOperation: RemoveSyncedMetadataOperation = { @@ -42,9 +54,17 @@ }, }; + const syncedMetadataStoreOperations = [ + ...predefinedStoreOperations, + removeOperation, + ]; + return { - syncedMetadataStore: processStoreOps(state, [removeOperation]), - syncedMetadataStoreOperations: [removeOperation], + syncedMetadataStore: processStoreOps( + state, + syncedMetadataStoreOperations, + ), + syncedMetadataStoreOperations, }; } else if (action.type === setClientDBStoreActionType) { const newSyncedMetadata = action.payload.syncedMetadata; @@ -68,8 +88,8 @@ } return { - syncedMetadataStore: state, - syncedMetadataStoreOperations: [], + syncedMetadataStore: processStoreOps(state, predefinedStoreOperations), + syncedMetadataStoreOperations: predefinedStoreOperations, }; }