Page MenuHomePhabricator

D12949.id43037.diff
No OneTemporary

D12949.id43037.diff

diff --git a/lib/reducers/dm-operations-queue-reducer.js b/lib/reducers/dm-operations-queue-reducer.js
new file mode 100644
--- /dev/null
+++ b/lib/reducers/dm-operations-queue-reducer.js
@@ -0,0 +1,26 @@
+// @flow
+
+import {
+ type QueuedDMOperations,
+ queueDMOpsActionType,
+} from '../types/dm-ops.js';
+import type { BaseAction } from '../types/redux-types.js';
+
+function reduceDMOperationsQueue(
+ store: QueuedDMOperations,
+ action: BaseAction,
+): QueuedDMOperations {
+ if (action.type === queueDMOpsActionType) {
+ const { threadID, operation } = action.payload;
+ return {
+ ...store,
+ operations: {
+ ...store.operations,
+ [threadID]: [...(store.operations[threadID] ?? []), operation],
+ },
+ };
+ }
+ return store;
+}
+
+export { reduceDMOperationsQueue };
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
@@ -7,6 +7,7 @@
import reduceCustomerServer from './custom-server-reducer.js';
import reduceDataLoaded from './data-loaded-reducer.js';
import { reduceDBOpsStore } from './db-ops-reducer.js';
+import { reduceDMOperationsQueue } from './dm-operations-queue-reducer.js';
import { reduceDraftStore } from './draft-reducer.js';
import reduceEnabledApps from './enabled-apps-reducer.js';
import { reduceEntryInfos } from './entry-reducer.js';
@@ -226,6 +227,10 @@
state.tunnelbrokerDeviceToken,
action,
),
+ queuedDMOperations: reduceDMOperationsQueue(
+ state.queuedDMOperations,
+ action,
+ ),
},
storeOperations: {
draftStoreOperations,
diff --git a/lib/shared/dm-ops/process-dm-ops.js b/lib/shared/dm-ops/process-dm-ops.js
--- a/lib/shared/dm-ops/process-dm-ops.js
+++ b/lib/shared/dm-ops/process-dm-ops.js
@@ -8,6 +8,7 @@
import {
type DMOperation,
processDMOpsActionType,
+ queueDMOpsActionType,
} from '../../types/dm-ops.js';
import { useDispatch, useSelector } from '../../utils/redux-utils.js';
@@ -38,7 +39,15 @@
utilities,
);
if (!processingCheckResult.isProcessingPossible) {
- // TODO queue for later
+ if (processingCheckResult.reason.type === 'missing_thread') {
+ dispatch({
+ type: queueDMOpsActionType,
+ payload: {
+ operation: dmOp,
+ threadID: processingCheckResult.reason.threadID,
+ },
+ });
+ }
return;
}
const { rawMessageInfos, updateInfos } = await dmOpSpecs[
diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js
--- a/lib/types/dm-ops.js
+++ b/lib/types/dm-ops.js
@@ -309,6 +309,12 @@
+updateInfos: $ReadOnlyArray<ClientUpdateInfo>,
};
+export const queueDMOpsActionType = 'QUEUE_DM_OPS';
+export type QueueDMOpsPayload = {
+ +operation: DMOperation,
+ +threadID: string,
+};
+
export const scheduleP2PMessagesActionType = 'SCHEDULE_P2P_MESSAGES';
export type ScheduleP2PMessagesPayload = {
+dmOpID: string,
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -44,6 +44,7 @@
ScheduleP2PMessagesPayload,
ProcessDMOpsPayload,
QueuedDMOperations,
+ QueueDMOpsPayload,
} from './dm-ops.js';
import type { DraftStore } from './draft-types.js';
import type { EnabledApps, SupportedApps } from './enabled-apps.js';
@@ -1579,7 +1580,8 @@
+payload: {
+deviceToken: string,
},
- },
+ }
+ | { +type: 'QUEUE_DM_OPS', +payload: QueueDMOpsPayload },
}>;
export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 1:37 AM (4 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2559325
Default Alt Text
D12949.id43037.diff (3 KB)

Event Timeline