Page MenuHomePhabricator

D5198.diff
No OneTemporary

D5198.diff

diff --git a/lib/shared/messages/multimedia-message-spec.js b/lib/shared/messages/multimedia-message-spec.js
--- a/lib/shared/messages/multimedia-message-spec.js
+++ b/lib/shared/messages/multimedia-message-spec.js
@@ -25,9 +25,9 @@
import type {
MediaMessageData,
MediaMessageInfo,
- MediaMessageServerDBContent,
RawMediaMessageInfo,
} from '../../types/messages/media';
+import { getMediaMessageServerDBContentsFromMedia } from '../../types/messages/media';
import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported';
import type { NotifTexts } from '../../types/notif-types';
import type { ThreadInfo } from '../../types/thread-types';
@@ -62,20 +62,9 @@
| RawImagesMessageInfo,
): string {
if (data.type === messageTypes.MULTIMEDIA) {
- const mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent> = data.media.map(
- media => {
- if (media.type === 'photo') {
- return { type: 'photo', uploadID: media.id };
- } else {
- return {
- type: 'video',
- uploadID: media.id,
- thumbnailUploadID: media.thumbnailID,
- };
- }
- },
+ return JSON.stringify(
+ getMediaMessageServerDBContentsFromMedia(data.media),
);
- return JSON.stringify(mediaMessageContents);
}
const mediaIDs = data.media.map(media => parseInt(media.id, 10));
return JSON.stringify(mediaIDs);
diff --git a/lib/types/messages/media.js b/lib/types/messages/media.js
--- a/lib/types/messages/media.js
+++ b/lib/types/messages/media.js
@@ -51,4 +51,23 @@
return uploadIDs;
}
-export { getUploadIDsFromMediaMessageServerDBContents };
+function getMediaMessageServerDBContentsFromMedia(
+ media: $ReadOnlyArray<Media>,
+): $ReadOnlyArray<MediaMessageServerDBContent> {
+ return media.map(m => {
+ if (m.type === 'photo') {
+ return { type: 'photo', uploadID: m.id };
+ } else {
+ return {
+ type: 'video',
+ uploadID: m.id,
+ thumbnailUploadID: m.thumbnailID,
+ };
+ }
+ });
+}
+
+export {
+ getUploadIDsFromMediaMessageServerDBContents,
+ getMediaMessageServerDBContentsFromMedia,
+};
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
@@ -58,6 +58,7 @@
MediaMessageServerDBContent,
RawMediaMessageInfo,
} from 'lib/types/messages/media';
+import { getMediaMessageServerDBContentsFromMedia } from 'lib/types/messages/media';
import type { RawTextMessageInfo } from 'lib/types/messages/text';
import type { Dispatch } from 'lib/types/redux-types';
import {
@@ -327,20 +328,9 @@
localID !== null && localID !== undefined,
'localID should be set',
);
- 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,
- };
- }
- },
+ const mediaMessageContents = getMediaMessageServerDBContentsFromMedia(
+ messageInfo.media,
);
-
try {
const result = await this.props.sendMultimediaMessage(
threadID,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 6:14 AM (18 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569396
Default Alt Text
D5198.diff (3 KB)

Event Timeline