Page MenuHomePhabricator

D12780.diff
No OneTemporary

D12780.diff

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
@@ -5,7 +5,11 @@
import { dmOpSpecs } from './dm-op-specs.js';
import { useLoggedInUserInfo } from '../../hooks/account-hooks.js';
import { useGetLatestMessageEdit } from '../../hooks/latest-message-edit.js';
-import type { DMOperation } from '../../types/dm-ops.js';
+import {
+ type DMOperation,
+ processDMOpsActionType,
+} from '../../types/dm-ops.js';
+import { useDispatch } from '../../utils/redux-utils.js';
function useProcessDMOperation(): (dmOp: DMOperation) => Promise<void> {
const fetchMessage = useGetLatestMessageEdit();
@@ -16,6 +20,7 @@
[fetchMessage],
);
+ const dispatch = useDispatch();
const loggedInUserInfo = useLoggedInUserInfo();
const viewerID = loggedInUserInfo?.id;
return React.useCallback(
@@ -24,10 +29,18 @@
console.log('ignored DMOperation because logged out');
return;
}
- await dmOpSpecs[dmOp.type].processDMOperation(dmOp, viewerID, utilities);
- // TODO: dispatch Redux action
+ const { rawMessageInfos, updateInfos } = await dmOpSpecs[
+ dmOp.type
+ ].processDMOperation(dmOp, viewerID, utilities);
+ dispatch({
+ type: processDMOpsActionType,
+ payload: {
+ rawMessageInfos,
+ updateInfos,
+ },
+ });
},
- [viewerID, utilities],
+ [dispatch, viewerID, utilities],
);
}
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
@@ -99,3 +99,10 @@
rawMessageInfos: Array<RawMessageInfo>,
updateInfos: Array<ClientUpdateInfo>,
};
+
+export const processDMOpsActionType = 'PROCESS_DM_OPS';
+
+export type ProcessDMOpsPayload = {
+ +rawMessageInfos: $ReadOnlyArray<RawMessageInfo>,
+ +updateInfos: $ReadOnlyArray<ClientUpdateInfo>,
+};
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
@@ -40,6 +40,7 @@
GetVersionActionPayload,
LastCommunicatedPlatformDetails,
} from './device-types.js';
+import type { ProcessDMOpsPayload } from './dm-ops.js';
import type { DraftStore } from './draft-types.js';
import type { EnabledApps, SupportedApps } from './enabled-apps.js';
import type {
@@ -1561,6 +1562,10 @@
+error: true,
+payload: Error,
+loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'PROCESS_DM_OPS',
+ +payload: ProcessDMOpsPayload,
},
}>;

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 6:20 AM (18 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599912
Default Alt Text
D12780.diff (2 KB)

Event Timeline