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 @@ -11,6 +11,9 @@ } from './dm-op-spec.js'; import { dmOpSpecs } from './dm-op-specs.js'; import { useProcessAndSendDMOperation } from './process-dm-ops.js'; +import { useFindUserIdentities } from '../../actions/user-actions.js'; +import { useLoggedInUserInfo } from '../../hooks/account-hooks.js'; +import { useGetLatestMessageEdit } from '../../hooks/latest-message-edit.js'; import { mergeUpdatesWithMessageInfos } from '../../reducers/message-reducer.js'; import type { CreateThickRawThreadInfoInput, @@ -391,10 +394,33 @@ }; } +function useSendDMOperationUtils(): $ReadOnly<{ + ...ProcessDMOperationUtilities, + viewerID: ?string, +}> { + const fetchMessage = useGetLatestMessageEdit(); + const threadInfos = useSelector(state => state.threadStore.threadInfos); + const entryInfos = useSelector(state => state.entryStore.entryInfos); + const findUserIdentities = useFindUserIdentities(); + const loggedInUserInfo = useLoggedInUserInfo(); + const viewerID = loggedInUserInfo?.id; + return React.useMemo( + () => ({ + viewerID, + fetchMessage, + threadInfos, + entryInfos, + findUserIdentities, + }), + [viewerID, fetchMessage, threadInfos, entryInfos, findUserIdentities], + ); +} + export { createMessagesToPeersFromDMOp, useAddDMThreadMembers, getCreateThickRawThreadInfoInputFromThreadInfo, getThreadUpdatesForNewMessages, checkMessageIDConflict, + useSendDMOperationUtils, }; 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,14 +13,10 @@ type OutboundComposableDMOperationSpecification, getThreadUpdatesForNewMessages, checkMessageIDConflict, + useSendDMOperationUtils, } from './dm-op-utils.js'; import { useProcessBlobHolders } from '../../actions/holder-actions.js'; -import { - processNewUserIDsActionType, - useFindUserIdentities, -} from '../../actions/user-actions.js'; -import { useLoggedInUserInfo } from '../../hooks/account-hooks.js'; -import { useGetLatestMessageEdit } from '../../hooks/latest-message-edit.js'; +import { processNewUserIDsActionType } from '../../actions/user-actions.js'; import { useDispatchWithMetadata } from '../../hooks/ops-hooks.js'; import { getAllPeerUserIDAndDeviceIDs } from '../../selectors/user-selectors.js'; import { @@ -38,25 +34,6 @@ import { extractUserIDsFromPayload } from '../../utils/conversion-utils.js'; import { useSelector, useDispatch } from '../../utils/redux-utils.js'; -function useSendDMOperationUtils() { - const fetchMessage = useGetLatestMessageEdit(); - const threadInfos = useSelector(state => state.threadStore.threadInfos); - const entryInfos = useSelector(state => state.entryStore.entryInfos); - const findUserIdentities = useFindUserIdentities(); - const loggedInUserInfo = useLoggedInUserInfo(); - const viewerID = loggedInUserInfo?.id; - return React.useMemo( - () => ({ - viewerID, - fetchMessage, - threadInfos, - entryInfos, - findUserIdentities, - }), - [viewerID, fetchMessage, threadInfos, entryInfos, findUserIdentities], - ); -} - function useProcessDMOperation(): ( dmOperationSpecification: DMOperationSpecification, dmOpID: ?string,