Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33152831
D13155.1768512852.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D13155.1768512852.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 15, 9:34 PM (6 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5940131
Default Alt Text
D13155.1768512852.diff (4 KB)
Attached To
Mode
D13155: [lib] implement action for sending DM messages
Attached
Detach File
Event Timeline
Log In to Comment