Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3520452
D5298.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5298.diff
View Options
diff --git a/lib/utils/message-ops-utils.js b/lib/utils/message-ops-utils.js
--- a/lib/utils/message-ops-utils.js
+++ b/lib/utils/message-ops-utils.js
@@ -12,17 +12,34 @@
type ClientDBMessageStoreOperation,
} from '../types/message-types';
-function translateMediaToClientDBMediaInfo(media: Media): ClientDBMediaInfo {
- return {
- id: media.id,
- uri: media.uri,
- type: media.type,
- extras: JSON.stringify({
- dimensions: media.dimensions,
- loop: media.type === 'video' ? media.loop : false,
- local_media_selection: media.localMediaSelection,
- }),
- };
+function translateMediaToClientDBMediaInfos(
+ media: $ReadOnlyArray<Media>,
+): $ReadOnlyArray<ClientDBMediaInfo> {
+ const clientDBMediaInfos = [];
+ for (const m of media) {
+ clientDBMediaInfos.push({
+ id: m.id,
+ uri: m.uri,
+ type: m.type,
+ extras: JSON.stringify({
+ dimensions: m.dimensions,
+ loop: m.type === 'video' ? m.loop : false,
+ local_media_selection: m.localMediaSelection,
+ }),
+ });
+ if (m.type === 'video') {
+ clientDBMediaInfos.push({
+ id: m.thumbnailID,
+ uri: m.thumbnailURI,
+ type: 'photo',
+ extras: JSON.stringify({
+ dimensions: m.dimensions,
+ loop: false,
+ }),
+ });
+ }
+ }
+ return clientDBMediaInfos;
}
function translateClientDBMediaInfoToImage(
@@ -69,7 +86,7 @@
media_infos:
rawMessageInfo.type === messageTypes.IMAGES ||
rawMessageInfo.type === messageTypes.MULTIMEDIA
- ? rawMessageInfo.media.map(translateMediaToClientDBMediaInfo)
+ ? translateMediaToClientDBMediaInfos(rawMessageInfo.media)
: null,
};
}
@@ -111,7 +128,6 @@
export {
translateClientDBMediaInfoToImage,
- translateMediaToClientDBMediaInfo,
translateRawMessageInfoToClientDBMessageInfo,
translateClientDBMessageInfoToRawMessageInfo,
translateClientDBMessageInfosToRawMessageInfos,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 12:22 AM (18 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2694617
Default Alt Text
D5298.diff (1 KB)
Attached To
Mode
D5298: [lib] Introduce `translateMediaToClientDBMediaInfos`
Attached
Detach File
Event Timeline
Log In to Comment