Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32162131
D15156.1765044634.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D15156.1765044634.diff
View Options
diff --git a/lib/ops/dm-operations-store-ops.js b/lib/ops/dm-operations-store-ops.js
--- a/lib/ops/dm-operations-store-ops.js
+++ b/lib/ops/dm-operations-store-ops.js
@@ -435,6 +435,8 @@
},
};
+export const dmOperationUnshimmedType = 'unshimmed_operation';
+
export {
convertDMOperationIntoClientDBDMOperation,
convertClientDBDMOperationToDMOperation,
diff --git a/lib/reducers/dm-operations-queue-reducer.js b/lib/reducers/dm-operations-queue-reducer.js
--- a/lib/reducers/dm-operations-queue-reducer.js
+++ b/lib/reducers/dm-operations-queue-reducer.js
@@ -1,15 +1,9 @@
// @flow
-import _mapValues from 'lodash/fp/mapValues.js';
-
-import {
- type DMOperationStoreOperation,
- addQueuedDMOpsToStore,
- removeQueuedDMOpsToStore,
-} from '../ops/dm-operations-store-ops.js';
+import type { DMOperationStoreOperation } from '../ops/dm-operations-store-ops.js';
+import { dmOperationsStoreOpsHandlers } from '../ops/dm-operations-store-ops.js';
import {
clearQueuedDMOpsActionType,
- type OperationsQueue,
pruneDMOpsQueueActionType,
type QueuedDMOperations,
queueDMOpsActionType,
@@ -18,6 +12,8 @@
} from '../types/dm-ops.js';
import type { BaseAction } from '../types/redux-types.js';
+const { processStoreOperations } = dmOperationsStoreOpsHandlers;
+
function reduceDMOperationsQueue(
store: QueuedDMOperations,
action: BaseAction,
@@ -26,45 +22,38 @@
+operations: $ReadOnlyArray<DMOperationStoreOperation>,
} {
if (action.type === queueDMOpsActionType) {
- const { condition, operation, timestamp } = action.payload;
-
+ const operations = [
+ { type: 'add_queued_dm_operation', payload: action.payload },
+ ];
return {
- store: addQueuedDMOpsToStore(store, condition, operation, timestamp),
- operations: [],
+ store: processStoreOperations(store, operations),
+ operations,
};
} else if (action.type === pruneDMOpsQueueActionType) {
- const filterOperations = (queue: OperationsQueue) =>
- queue.filter(op => op.timestamp >= action.payload.pruneMaxTimestamp);
+ const operations = [
+ { type: 'prune_queued_dm_operations', payload: action.payload },
+ ];
return {
- store: {
- ...store,
- threadQueue: _mapValues(operations => filterOperations(operations))(
- store.threadQueue,
- ),
- messageQueue: _mapValues(operations => filterOperations(operations))(
- store.messageQueue,
- ),
- entryQueue: _mapValues(operations => filterOperations(operations))(
- store.entryQueue,
- ),
- membershipQueue: _mapValues(threadMembershipQueue =>
- _mapValues(operations => filterOperations(operations))(
- threadMembershipQueue,
- ),
- )(store.membershipQueue),
- },
- operations: [],
+ store: processStoreOperations(store, operations),
+ operations,
};
} else if (action.type === clearQueuedDMOpsActionType) {
- const condition = action.payload;
-
+ const operations = [
+ {
+ type: 'clear_dm_operations_queue',
+ payload: { condition: action.payload },
+ },
+ ];
return {
- store: removeQueuedDMOpsToStore(store, condition),
- operations: [],
+ store: processStoreOperations(store, operations),
+ operations,
};
} else if (action.type === saveUnsupportedOperationActionType) {
return {
store,
+ // DM Operation is saved directly to the database because this
+ // client can't handle it. It can be retrieved later using
+ // migration and unshimmed.
operations: [
{
type: 'replace_dm_operation',
@@ -77,21 +66,17 @@
],
};
} else if (action.type === reportUnshimmingOperationCompletedActionType) {
- return {
- store: {
- ...store,
- shimmedOperations: store.shimmedOperations.filter(
- op => op.id !== action.payload.id,
- ),
- },
- operations: [
- {
- type: 'remove_dm_operations',
- payload: {
- ids: [action.payload.id],
- },
+ const operations = [
+ {
+ type: 'remove_dm_operations',
+ payload: {
+ ids: [action.payload.id],
},
- ],
+ },
+ ];
+ return {
+ store: processStoreOperations(store, operations),
+ operations,
};
}
return { store, operations: [] };
diff --git a/lib/shared/unshim-utils.js b/lib/shared/unshim-utils.js
--- a/lib/shared/unshim-utils.js
+++ b/lib/shared/unshim-utils.js
@@ -6,6 +6,7 @@
import {
type ClientDBDMOperation,
convertClientDBDMOperationToDMOperation,
+ dmOperationUnshimmedType,
} from '../ops/dm-operations-store-ops.js';
import { type DMOperationType } from '../types/dm-ops.js';
import { type MessageType, messageTypes } from '../types/message-types-enum.js';
@@ -87,6 +88,18 @@
operation: op.operation,
}));
+ const dmOperationStoreOperations = shimmedOperations.map(op => ({
+ type: 'replace_dm_operation',
+ payload: {
+ id: op.id,
+ // This is replaced with hardcoded type to later, when reading DB,
+ // add it to store the same way as it is done in this migration,
+ // and attempt processing this.
+ type: dmOperationUnshimmedType,
+ operation: op.operation,
+ },
+ }));
+
return {
state: {
...state,
@@ -95,7 +108,7 @@
shimmedOperations,
},
},
- ops: {},
+ ops: { dmOperationStoreOperations },
};
} catch (e) {
console.log(e);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 6:10 PM (19 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5840021
Default Alt Text
D15156.1765044634.diff (5 KB)
Attached To
Mode
D15156: [lib] refactor QueuedDMOperations reducer to ops pattern
Attached
Detach File
Event Timeline
Log In to Comment