diff --git a/lib/hooks/input-state-container-hooks.js b/lib/hooks/input-state-container-hooks.js --- a/lib/hooks/input-state-container-hooks.js +++ b/lib/hooks/input-state-container-hooks.js @@ -48,6 +48,13 @@ } from '../utils/blob-service.js'; import { useSelector, useDispatch } from '../utils/redux-utils.js'; +type MediaIDUpdatePayload = { +id: string, +thumbnailID?: string }; +type MediaIDUpdates = { +[string]: MediaIDUpdatePayload }; +export type SendMultimediaMessagePayload = { + +result: SendMessagePayload, + +mediaIDUpdates?: MediaIDUpdates, +}; + function useInputStateContainerSendTextMessage(): ( messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, @@ -134,7 +141,7 @@ messageInfo: RawMultimediaMessageInfo, sidebarCreation: boolean, isLegacy: boolean, -) => Promise { +) => Promise { const sendMultimediaMessage = useSendMultimediaMessage(); const legacySendMultimediaMessage = useLegacySendMultimediaMessage(); const sendComposableDMOperation = useSendComposableDMOperation(); @@ -160,12 +167,13 @@ const isThickThread = threadInfo && threadTypeIsThick(threadInfo.type); if (!isThickThread && isLegacy) { - const { messageMedia } = await migrateMessageMediaToKeyserver( - messageInfo, - reassignThickThreadMedia, - dispatch, - processHolders, - ); + const { messageMedia, mediaIDUpdates } = + await migrateMessageMediaToKeyserver( + messageInfo, + reassignThickThreadMedia, + dispatch, + processHolders, + ); const mediaIDs = []; for (const { id } of messageMedia) { mediaIDs.push(id); @@ -177,20 +185,24 @@ sidebarCreation, }); return { - localID, - serverID: result.id, - threadID: messageInfo.threadID, - time: result.time, + result: { + localID, + serverID: result.id, + threadID: messageInfo.threadID, + time: result.time, + }, + mediaIDUpdates, }; } if (!isThickThread && !isLegacy) { - const { messageMedia } = await migrateMessageMediaToKeyserver( - messageInfo, - reassignThickThreadMedia, - dispatch, - processHolders, - ); + const { messageMedia, mediaIDUpdates } = + await migrateMessageMediaToKeyserver( + messageInfo, + reassignThickThreadMedia, + dispatch, + processHolders, + ); const mediaMessageContents = getMediaMessageServerDBContentsFromMedia(messageMedia); const result = await sendMultimediaMessage({ @@ -200,10 +212,13 @@ sidebarCreation, }); return { - localID, - serverID: result.id, - threadID: messageInfo.threadID, - time: result.time, + result: { + localID, + serverID: result.id, + threadID: messageInfo.threadID, + time: result.time, + }, + mediaIDUpdates, }; } @@ -238,10 +253,12 @@ throw e; } return { - localID, - serverID: messageID, - threadID: messageInfo.threadID, - time, + result: { + localID, + serverID: messageID, + threadID: messageInfo.threadID, + time, + }, }; }, [ @@ -260,9 +277,6 @@ return mediaID.indexOf('|') !== -1; } -type MediaIDUpdatePayload = { +id: string, +thumbnailID?: string }; -type MediaIDUpdates = { +[string]: MediaIDUpdatePayload }; - async function migrateMessageMediaToKeyserver( messageInfo: RawMultimediaMessageInfo, reassignMediaMetadata: MediaMetadataReassignmentAction, diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js --- a/native/input/input-state-container.react.js +++ b/native/input/input-state-container.react.js @@ -24,6 +24,7 @@ } from 'lib/actions/upload-actions.js'; import commStaffCommunity from 'lib/facts/comm-staff-community.js'; import { + type SendMultimediaMessagePayload, useInputStateContainerSendMultimediaMessage, useInputStateContainerSendTextMessage, } from 'lib/hooks/input-state-container-hooks.js'; @@ -157,7 +158,7 @@ messageInfo: RawMultimediaMessageInfo, sidebarCreation: boolean, isLegacy: boolean, - ) => Promise, + ) => Promise, +sendTextMessage: ( messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, @@ -394,7 +395,7 @@ const sidebarCreation = this.pendingSidebarCreationMessageLocalIDs.has(localID); try { - const result = await this.props.sendMultimediaMessage( + const { result } = await this.props.sendMultimediaMessage( messageInfo, sidebarCreation, false, diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -34,6 +34,7 @@ import blobService from 'lib/facts/blob-service.js'; import commStaffCommunity from 'lib/facts/comm-staff-community.js'; import { + type SendMultimediaMessagePayload, useInputStateContainerSendMultimediaMessage, useInputStateContainerSendTextMessage, } from 'lib/hooks/input-state-container-hooks.js'; @@ -152,7 +153,7 @@ messageInfo: RawMultimediaMessageInfo, sidebarCreation: boolean, isLegacy: boolean, - ) => Promise, + ) => Promise, +sendTextMessage: ( messageInfo: RawTextMessageInfo, threadInfo: ThreadInfo, @@ -549,7 +550,7 @@ const sidebarCreation = this.pendingSidebarCreationMessageLocalIDs.has(localID); try { - const result = await this.props.sendMultimediaMessage( + const { result } = await this.props.sendMultimediaMessage( messageInfo, sidebarCreation, true,