Page MenuHomePhabricator

D13155.diff
No OneTemporary

D13155.diff

diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -79,7 +79,7 @@
import { unshimMessageInfos } from '../shared/unshim-utils.js';
import { updateSpecs } from '../shared/updates/update-specs.js';
import { recoveryFromReduxActionSources } from '../types/account-types.js';
-import { processDMOpsActionType } from '../types/dm-ops.js';
+import { processDMOpsActionType, sendDMActionTypes } from '../types/dm-ops.js';
import type { Media, Image } from '../types/media-types.js';
import { messageTypes } from '../types/message-types-enum.js';
import {
@@ -1868,6 +1868,63 @@
localOperation,
]),
};
+ } else if (action.type === sendDMActionTypes.success) {
+ const { messageID: sentMessageID, outboundP2PMessageIDs } = action.payload;
+
+ const outboundP2PMessageIDsSet = new Set(outboundP2PMessageIDs);
+ const localOutboundP2PMessageIDs =
+ messageStore.local[sentMessageID]?.outboundP2PMessageIDs ?? [];
+ const remainingOutboundP2PMessageIDs = localOutboundP2PMessageIDs.filter(
+ id => !outboundP2PMessageIDsSet.has(id),
+ );
+
+ const messageStoreOperations: Array<MessageStoreOperation> = [];
+ if (remainingOutboundP2PMessageIDs.length > 0) {
+ messageStoreOperations.push({
+ type: 'replace_local_message_info',
+ payload: {
+ id: sentMessageID,
+ localMessageInfo: {
+ sendFailed: true,
+ outboundP2PMessageIDs: remainingOutboundP2PMessageIDs,
+ },
+ },
+ });
+ } else {
+ messageStoreOperations.push({
+ type: 'remove_local_message_infos',
+ payload: {
+ ids: [sentMessageID],
+ },
+ });
+ }
+
+ return {
+ messageStoreOperations,
+ messageStore: processMessageStoreOperations(
+ messageStore,
+ messageStoreOperations,
+ ),
+ };
+ } else if (action.type === sendDMActionTypes.started) {
+ const { messageID: sentMessageID } = action.payload;
+ const localOperation: ReplaceMessageStoreLocalMessageInfoOperation = {
+ type: 'replace_local_message_info',
+ payload: {
+ id: sentMessageID,
+ localMessageInfo: {
+ ...messageStore.local[sentMessageID],
+ sendFailed: false,
+ },
+ },
+ };
+
+ return {
+ messageStoreOperations: [localOperation],
+ messageStore: processMessageStoreOperations(messageStore, [
+ localOperation,
+ ]),
+ };
}
return { messageStoreOperations: [], messageStore };
}
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
@@ -383,3 +383,18 @@
}>,
},
};
+
+export type SendDMStartedPayload = {
+ +messageID: string,
+};
+
+export type SendDMOpsSuccessPayload = {
+ +messageID: string,
+ +outboundP2PMessageIDs: $ReadOnlyArray<string>,
+};
+
+export const sendDMActionTypes = Object.freeze({
+ started: 'SEND_DM_STARTED',
+ success: 'SEND_DM_SUCCESS',
+ failed: 'SEND_DM_FAILED',
+});
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
@@ -47,6 +47,8 @@
QueueDMOpsPayload,
PruneDMOpsQueuePayload,
ClearQueuedThreadDMOpsPayload,
+ SendDMStartedPayload,
+ SendDMOpsSuccessPayload,
} from './dm-ops.js';
import type { DraftStore } from './draft-types.js';
import type { EnabledApps, SupportedApps } from './enabled-apps.js';
@@ -1578,6 +1580,22 @@
+type: 'PROCESS_DM_OPS',
+payload: ProcessDMOpsPayload,
}
+ | {
+ +type: 'SEND_DM_STARTED',
+ +payload: SendDMStartedPayload,
+ +loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'SEND_DM_FAILED',
+ +error: true,
+ +payload: Error,
+ +loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'SEND_DM_SUCCESS',
+ +payload: SendDMOpsSuccessPayload,
+ +loadingInfo: LoadingInfo,
+ }
| {
+type: 'INVALIDATE_TUNNELBROKER_DEVICE_TOKEN',
+payload: {

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 2:47 PM (22 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585173
Default Alt Text
D13155.diff (4 KB)

Event Timeline