Page MenuHomePhabricator

D5063.id16877.diff
No OneTemporary

D5063.id16877.diff

diff --git a/lib/actions/message-actions.js b/lib/actions/message-actions.js
--- a/lib/actions/message-actions.js
+++ b/lib/actions/message-actions.js
@@ -7,6 +7,7 @@
SendMessageResult,
SimpleMessagesPayload,
} from '../types/message-types';
+import type { MediaMessageServerDBContent } from '../types/messages/media.js';
import type { FetchJSON, FetchResultInfo } from '../utils/fetch-json';
const fetchMessagesBeforeCursorActionTypes = Object.freeze({
@@ -124,6 +125,42 @@
success: 'SEND_MULTIMEDIA_MESSAGE_SUCCESS',
failed: 'SEND_MULTIMEDIA_MESSAGE_FAILED',
});
+const sendMultimediaMessage = (
+ fetchJSON: FetchJSON,
+): ((
+ threadID: string,
+ localID: string,
+ mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent>,
+) => Promise<SendMessageResult>) => async (
+ threadID,
+ localID,
+ mediaMessageContents,
+) => {
+ let resultInfo;
+ const getResultInfo = (passedResultInfo: FetchResultInfo) => {
+ resultInfo = passedResultInfo;
+ };
+ const response = await fetchJSON(
+ 'create_multimedia_message',
+ {
+ threadID,
+ localID,
+ mediaMessageContents,
+ },
+ { getResultInfo },
+ );
+ const resultInterface = resultInfo?.interface;
+ invariant(
+ resultInterface,
+ 'getResultInfo not called before fetchJSON resolves',
+ );
+ return {
+ id: response.newMessageInfo.id,
+ time: response.newMessageInfo.time,
+ interface: resultInterface,
+ };
+};
+
const legacySendMultimediaMessage = (
fetchJSON: FetchJSON,
): ((
@@ -172,6 +209,7 @@
sendTextMessage,
createLocalMessageActionType,
sendMultimediaMessageActionTypes,
+ sendMultimediaMessage,
legacySendMultimediaMessage,
saveMessagesActionType,
processMessagesActionType,
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
@@ -10,7 +10,7 @@
import {
createLocalMessageActionType,
sendMultimediaMessageActionTypes,
- legacySendMultimediaMessage,
+ sendMultimediaMessage,
sendTextMessageActionTypes,
sendTextMessage,
} from 'lib/actions/message-actions';
@@ -54,7 +54,10 @@
type SendMessagePayload,
} from 'lib/types/message-types';
import type { RawImagesMessageInfo } from 'lib/types/messages/images';
-import type { RawMediaMessageInfo } from 'lib/types/messages/media';
+import type {
+ MediaMessageServerDBContent,
+ RawMediaMessageInfo,
+} from 'lib/types/messages/media';
import type { RawTextMessageInfo } from 'lib/types/messages/text';
import type { Dispatch } from 'lib/types/redux-types';
import {
@@ -122,7 +125,7 @@
+sendMultimediaMessage: (
threadID: string,
localID: string,
- mediaIDs: $ReadOnlyArray<string>,
+ mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent>,
) => Promise<SendMessageResult>,
+sendTextMessage: (
threadID: string,
@@ -324,15 +327,25 @@
localID !== null && localID !== undefined,
'localID should be set',
);
- const mediaIDs = [];
- for (const { id } of messageInfo.media) {
- mediaIDs.push(id);
- }
+ const mediaMessageContents: MediaMessageServerDBContent[] = messageInfo.media.map(
+ media => {
+ if (media.type === 'photo') {
+ return { type: 'photo', uploadID: media.id };
+ } else {
+ return {
+ type: 'video',
+ uploadID: media.id,
+ thumbnailUploadID: media.thumbnailID,
+ };
+ }
+ },
+ );
+
try {
const result = await this.props.sendMultimediaMessage(
threadID,
localID,
- mediaIDs,
+ mediaMessageContents,
);
return {
localID,
@@ -1383,9 +1396,7 @@
const hasWiFi = useSelector(state => state.connectivity.hasWiFi);
const calendarQuery = useCalendarQuery();
const callUploadMultimedia = useServerCall(uploadMultimedia);
- const callSendMultimediaMessage = useServerCall(
- legacySendMultimediaMessage,
- );
+ const callSendMultimediaMessage = useServerCall(sendMultimediaMessage);
const callSendTextMessage = useServerCall(sendTextMessage);
const callNewThread = useServerCall(newThread);
const dispatchActionPromise = useDispatchActionPromise();

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 2:30 PM (20 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585121
Default Alt Text
D5063.id16877.diff (4 KB)

Event Timeline