Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33311185
D8371.1768810318.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D8371.1768810318.diff
View Options
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -1437,12 +1437,20 @@
singleMedia.type === 'encrypted_photo' &&
mediaUpdate.type === 'encrypted_photo'
) {
+ // TODO: Remove this $FlowFixMe after updating Flow to 0.202
+ // There's no way in Flow to refine both of these types appropriately
+ // so they can be spread together.
+ // $FlowFixMe
media.push({ ...singleMedia, ...mediaUpdate });
replaced = true;
} else if (
singleMedia.type === 'encrypted_video' &&
mediaUpdate.type === 'encrypted_video'
) {
+ // TODO: Remove this $FlowFixMe after updating Flow to 0.202
+ // There's no way in Flow to refine both of these types appropriately
+ // so they can be spread together.
+ // $FlowFixMe
media.push({ ...singleMedia, ...mediaUpdate });
replaced = true;
} else if (
@@ -1451,16 +1459,22 @@
) {
// extract fields that are absent in encrypted_photo type
const { uri, localMediaSelection, ...original } = singleMedia;
- const { holder, encryptionKey, ...update } = mediaUpdate;
+ const {
+ holder: newHolder,
+ blobURI: newBlobURI,
+ encryptionKey,
+ ...update
+ } = mediaUpdate;
+ const blobURI = newBlobURI ?? newHolder;
invariant(
- holder && encryptionKey,
+ blobURI && encryptionKey,
'holder and encryptionKey are required for encrypted_photo message',
);
media.push({
...original,
...update,
type: 'encrypted_photo',
- holder,
+ blobURI,
encryptionKey,
});
replaced = true;
@@ -1471,18 +1485,22 @@
const { uri, thumbnailURI, localMediaSelection, ...original } =
singleMedia;
const {
- holder,
+ holder: newHolder,
+ blobURI: newBlobURI,
encryptionKey,
- thumbnailHolder,
+ thumbnailHolder: newThumbnailHolder,
+ thumbnailBlobURI: newThumbnailBlobURI,
thumbnailEncryptionKey,
...update
} = mediaUpdate;
+ const blobURI = newBlobURI ?? newHolder;
invariant(
- holder && encryptionKey,
+ blobURI && encryptionKey,
'holder and encryptionKey are required for encrypted_video message',
);
+ const thumbnailBlobURI = newThumbnailBlobURI ?? newThumbnailHolder;
invariant(
- thumbnailHolder && thumbnailEncryptionKey,
+ thumbnailBlobURI && thumbnailEncryptionKey,
'thumbnailHolder and thumbnailEncryptionKey are required for ' +
'encrypted_video message',
);
@@ -1490,9 +1508,9 @@
...original,
...update,
type: 'encrypted_video',
- holder,
+ blobURI,
encryptionKey,
- thumbnailHolder,
+ thumbnailBlobURI,
thumbnailEncryptionKey,
});
replaced = true;
@@ -1504,9 +1522,27 @@
} else if (singleMedia.type === 'video') {
media.push({ ...singleMedia, id: newID });
} else if (singleMedia.type === 'encrypted_photo') {
- media.push({ ...singleMedia, id: newID });
+ // TODO: Try removing this branching after Flow 0.202 update
+ if (singleMedia.blobURI) {
+ media.push({ ...singleMedia, id: newID });
+ } else {
+ invariant(
+ singleMedia.holder,
+ 'Encrypted media must have holder or blobURI',
+ );
+ media.push({ ...singleMedia, id: newID });
+ }
} else if (singleMedia.type === 'encrypted_video') {
- media.push({ ...singleMedia, id: newID });
+ // TODO: Try removing this branching after Flow 0.202 update
+ if (singleMedia.blobURI) {
+ media.push({ ...singleMedia, id: newID });
+ } else {
+ invariant(
+ singleMedia.holder,
+ 'Encrypted media must have holder or blobURI',
+ );
+ media.push({ ...singleMedia, id: newID });
+ }
}
replaced = true;
}
diff --git a/lib/types/media-types.js b/lib/types/media-types.js
--- a/lib/types/media-types.js
+++ b/lib/types/media-types.js
@@ -77,7 +77,7 @@
export type UpdateMultimediaMessageMediaPayload = {
+messageID: string,
+currentMediaID: string,
- +mediaUpdate: Shape<Media>,
+ +mediaUpdate: MediaShape,
};
export type UploadDeletionRequest = {
@@ -763,6 +763,11 @@
]);
export type Media = Image | Video | EncryptedImage | EncryptedVideo;
+export type MediaShape =
+ | Shape<Image>
+ | Shape<Video>
+ | Shape<EncryptedImage>
+ | Shape<EncryptedVideo>;
export const mediaValidator: TUnion<Media> = t.union([
imageValidator,
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
@@ -974,7 +974,7 @@
processedMedia.mediaType === 'encrypted_video'
? {
type: processedMedia.mediaType,
- holder: uri,
+ blobURI: uri,
encryptionKey,
}
: {
@@ -1008,7 +1008,7 @@
mediaUpdate: {
...updateMediaPayload.mediaUpdate,
thumbnailID,
- thumbnailHolder: thumbnailURI,
+ thumbnailBlobURI: thumbnailURI,
thumbnailEncryptionKey,
thumbnailThumbHash,
},
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
@@ -349,7 +349,7 @@
);
return {
id: serverID ? serverID : localID,
- holder: uri,
+ blobURI: uri,
type: 'encrypted_photo',
encryptionKey,
dimensions: shimmedDimensions,
@@ -1017,7 +1017,7 @@
mediaUpdate = {
...mediaUpdate,
type: outputMediaType,
- holder: uri,
+ blobURI: uri,
encryptionKey,
};
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 8:11 AM (9 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5955345
Default Alt Text
D8371.1768810318.diff (6 KB)
Attached To
Mode
D8371: [lib] Workaround Flow issues in messages-reducer
Attached
Detach File
Event Timeline
Log In to Comment