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 @@ -13,6 +13,7 @@ createMessagesToPeersFromDMOp, dmOperationSpecificationTypes, } from './dm-op-utils.js'; +import { processNewUserIDsActionType } from '../../actions/user-actions.js'; import { useLoggedInUserInfo } from '../../hooks/account-hooks.js'; import { useGetLatestMessageEdit } from '../../hooks/latest-message-edit.js'; import { useDispatchWithMetadata } from '../../hooks/ops-hooks.js'; @@ -25,6 +26,7 @@ sendDMActionTypes, type SendDMOpsSuccessPayload, } from '../../types/dm-ops.js'; +import { dmOperationValidator } from '../../types/dm-ops.js'; import type { LocalMessageInfo } from '../../types/message-types.js'; import type { RawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js'; import type { DispatchMetadata } from '../../types/redux-types.js'; @@ -32,8 +34,9 @@ import { threadTypes } from '../../types/thread-types-enum.js'; import type { LegacyRawThreadInfo } from '../../types/thread-types.js'; import { updateTypes } from '../../types/update-types-enum.js'; +import { extractUserIDsFromPayload } from '../../utils/conversion-utils.js'; import { useDispatchActionPromise } from '../../utils/redux-promise-utils.js'; -import { useSelector } from '../../utils/redux-utils.js'; +import { useSelector, useDispatch } from '../../utils/redux-utils.js'; import { messageSpecs } from '../messages/message-specs.js'; import { updateSpecs } from '../updates/update-specs.js'; @@ -58,6 +61,8 @@ const allPeerUserIDAndDeviceIDs = useSelector(getAllPeerUserIDAndDeviceIDs); const currentUserInfo = useSelector(state => state.currentUserInfo); + const dispatch = useDispatch(); + return React.useCallback( async ( dmOperationSpecification: DMOperationSpecification, @@ -153,6 +158,14 @@ return; } + const newUserIDs = extractUserIDsFromPayload(dmOperationValidator, dmOp); + if (newUserIDs.length > 0) { + dispatch({ + type: processNewUserIDsActionType, + payload: { userIDs: newUserIDs }, + }); + } + const dmOpSpec = dmOpSpecs[dmOp.type]; const notificationsCreationDataPromise = (async () => { return await dmOpSpec.notificationsCreationData?.(dmOp, utilities); @@ -251,6 +264,7 @@ allPeerUserIDAndDeviceIDs, currentUserInfo, threadInfos, + dispatch, ], ); }