Page MenuHomePhabricator

D11280.diff
No OneTemporary

D11280.diff

diff --git a/lib/reducers/db-ops-reducer.js b/lib/reducers/db-ops-reducer.js
new file mode 100644
--- /dev/null
+++ b/lib/reducers/db-ops-reducer.js
@@ -0,0 +1,18 @@
+// @flow
+
+import { opsProcessingFinishedActionType } from '../actions/db-ops-actions.js';
+import type { DBOpsStore } from '../types/db-ops-types.js';
+import type { BaseAction } from '../types/redux-types.js';
+
+function reduceDBOpsStore(store: DBOpsStore, action: BaseAction): DBOpsStore {
+ if (action.type === opsProcessingFinishedActionType) {
+ const [, ...rest] = store.queuedOps;
+ return {
+ ...store,
+ queuedOps: rest,
+ };
+ }
+ return store;
+}
+
+export { reduceDBOpsStore };
diff --git a/lib/reducers/db-ops-reducer.test.js b/lib/reducers/db-ops-reducer.test.js
new file mode 100644
--- /dev/null
+++ b/lib/reducers/db-ops-reducer.test.js
@@ -0,0 +1,34 @@
+// @flow
+
+import { reduceDBOpsStore } from './db-ops-reducer.js';
+import { opsProcessingFinishedActionType } from '../actions/db-ops-actions.js';
+import type { DBOpsStore } from '../types/db-ops-types.js';
+
+const emptyOps = {
+ draftStoreOperations: [],
+ threadStoreOperations: [],
+ messageStoreOperations: [],
+ reportStoreOperations: [],
+ userStoreOperations: [],
+ keyserverStoreOperations: [],
+ communityStoreOperations: [],
+ integrityStoreOperations: [],
+};
+
+describe('DB ops reducer', () => {
+ const store: DBOpsStore = {
+ queuedOps: [
+ { ops: emptyOps, messageID: '5' },
+ { ops: emptyOps },
+ { ops: null, messageID: '7' },
+ ],
+ };
+
+ it('should remove the first entry', () => {
+ const newState = reduceDBOpsStore(store, {
+ type: opsProcessingFinishedActionType,
+ });
+ expect(newState.queuedOps.length).toEqual(2);
+ expect(newState.queuedOps[1].messageID).toEqual('7');
+ });
+});
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
@@ -4,6 +4,7 @@
import { reduceCommunityStore } from './community-reducer.js';
import reduceCustomerServer from './custom-server-reducer.js';
import reduceDataLoaded from './data-loaded-reducer.js';
+import { reduceDBOpsStore } from './db-ops-reducer.js';
import { reduceDraftStore } from './draft-reducer.js';
import reduceEnabledApps from './enabled-apps-reducer.js';
import { reduceEntryInfos } from './entry-reducer.js';
@@ -209,6 +210,7 @@
globalThemeInfo: reduceGlobalThemeInfo(state.globalThemeInfo, action),
customServer: reduceCustomerServer(state.customServer, action),
communityStore,
+ dbOpsStore: reduceDBOpsStore(state.dbOpsStore, action),
},
storeOperations: {
draftStoreOperations,

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 12:53 PM (20 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2575739
Default Alt Text
D11280.diff (2 KB)

Event Timeline