Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3506957
D13123.id43558.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13123.id43558.diff
View Options
diff --git a/lib/shared/dm-ops/dm-op-utils.js b/lib/shared/dm-ops/dm-op-utils.js
--- a/lib/shared/dm-ops/dm-op-utils.js
+++ b/lib/shared/dm-ops/dm-op-utils.js
@@ -2,7 +2,10 @@
import uuid from 'uuid';
+import type { ProcessDMOperationUtilities } from './dm-op-spec.js';
+import { dmOpSpecs } from './dm-op-specs.js';
import type { DMOperation } from '../../types/dm-ops.js';
+import type { NotificationsCreationData } from '../../types/notif-types.js';
import {
outboundP2PMessageStatuses,
type OutboundP2PMessage,
@@ -87,4 +90,12 @@
);
}
-export { createMessagesToPeersFromDMOp };
+async function getNotificationsCreationDataFromDMOp(
+ operation: DMOperationSpecification,
+ utilities: ProcessDMOperationUtilities,
+): Promise<?NotificationsCreationData> {
+ const { op } = operation;
+ return await dmOpSpecs[op.type].notificationsCreationData?.(op, utilities);
+}
+
+export { createMessagesToPeersFromDMOp, getNotificationsCreationDataFromDMOp };
diff --git a/lib/tunnelbroker/peer-to-peer-context.js b/lib/tunnelbroker/peer-to-peer-context.js
--- a/lib/tunnelbroker/peer-to-peer-context.js
+++ b/lib/tunnelbroker/peer-to-peer-context.js
@@ -9,9 +9,11 @@
useTunnelbroker,
} from './tunnelbroker-context.js';
import { usePeerOlmSessionsCreatorContext } from '../components/peer-olm-session-creator-provider.react.js';
+import { useGetLatestMessageEdit } from '../hooks/latest-message-edit.js';
import { getAllPeerUserIDAndDeviceIDs } from '../selectors/user-selectors.js';
import {
createMessagesToPeersFromDMOp,
+ getNotificationsCreationDataFromDMOp,
type DMOperationSpecification,
} from '../shared/dm-ops/dm-op-utils.js';
import {
@@ -178,6 +180,17 @@
const allPeerUserIDAndDeviceIDs = useSelector(getAllPeerUserIDAndDeviceIDs);
const currentUserInfo = useSelector(state => state.currentUserInfo);
+ const fetchMessage = useGetLatestMessageEdit();
+ const threadInfos = useSelector(state => state.threadStore.threadInfos);
+
+ const utilities = React.useMemo(
+ () => ({
+ fetchMessage,
+ threadInfos,
+ }),
+ [fetchMessage, threadInfos],
+ );
+
const sendDMOperation = React.useCallback(
async (op: DMOperationSpecification) => {
const dmOpID = uuid.v4();
@@ -190,18 +203,21 @@
allPeerUserIDAndDeviceIDs,
currentUserInfo,
);
+ const notificationsCreationData =
+ await getNotificationsCreationDataFromDMOp(op, utilities);
dispatch({
type: scheduleP2PMessagesActionType,
payload: {
dmOpID,
messages,
+ notificationsCreationData,
},
});
return promise;
},
- [allPeerUserIDAndDeviceIDs, currentUserInfo, dispatch],
+ [utilities, allPeerUserIDAndDeviceIDs, currentUserInfo, dispatch],
);
const processingQueue = React.useRef<
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 6:40 PM (20 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2688739
Default Alt Text
D13123.id43558.diff (2 KB)
Attached To
Mode
D13123: Update sendDMOperation to send notifs as well
Attached
Detach File
Event Timeline
Log In to Comment