Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3406360
D8371.id28256.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D8371.id28256.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
@@ -1371,7 +1371,15 @@
messageStore: newMessageStore,
};
} else if (action.type === updateMultimediaMessageMediaActionType) {
- const { messageID: id, currentMediaID, mediaUpdate } = action.payload;
+ const {
+ messageID: id,
+ currentMediaID,
+ mediaUpdate: _mediaUpdate,
+ } = action.payload;
+ // TODO: Remove this any-cast after RN 0.72 / Flow 0.202 update
+ // This is a workaround because `Shape<Media>` contains nested union types
+ // which current version of Flow cannot handle properly
+ const mediaUpdate = (_mediaUpdate: any);
const message = messageStore.messages[id];
invariant(message, `message with ID ${id} could not be found`);
invariant(
@@ -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,8 +1522,12 @@
} else if (singleMedia.type === 'video') {
media.push({ ...singleMedia, id: newID });
} else if (singleMedia.type === 'encrypted_photo') {
+ // TODO: This should work after RN 0.72 / Flow 0.202 update
+ // $FlowFixMe
media.push({ ...singleMedia, id: newID });
} else if (singleMedia.type === 'encrypted_video') {
+ // TODO: This should work after RN 0.72 / Flow 0.202 update
+ // $FlowFixMe
media.push({ ...singleMedia, id: newID });
}
replaced = true;
diff --git a/lib/reducers/message-reducer.test.js b/lib/reducers/message-reducer.test.js
--- a/lib/reducers/message-reducer.test.js
+++ b/lib/reducers/message-reducer.test.js
@@ -66,6 +66,8 @@
};
const { messageStore: updatedMessageStore } = reduceMessageStore(
messageStoreBeforeMediaUpdate,
+ // TODO: This should work after RN 0.72 / Flow 0.202 update
+ // $FlowFixMe
updateMultiMediaMessageMediaAction,
{},
);
@@ -121,6 +123,8 @@
const { messageStore: storeWithoutLocalMediaSelectionUpdate } =
reduceMessageStore(
messageStoreBeforeMediaUpdate,
+ // TODO: This should work after RN 0.72 / Flow 0.202 update
+ // $FlowFixMe
actionWithoutLocalMediaSelectionUpdate,
{},
);
@@ -173,6 +177,8 @@
const { messageStore: updatedMessageStoreWithReplacement } =
reduceMessageStore(
messageStoreBeforeMediaUpdate,
+ // TODO: This should work after RN 0.72 / Flow 0.202 update
+ // $FlowFixMe
updateMultiMediaMessageMediaActionWithReplacement,
{},
);
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
@@ -348,7 +348,7 @@
);
return {
id: serverID ? serverID : localID,
- holder: uri,
+ blobURI: uri,
type: 'encrypted_photo',
encryptionKey,
dimensions: shimmedDimensions,
@@ -1016,7 +1016,7 @@
mediaUpdate = {
...mediaUpdate,
type: outputMediaType,
- holder: uri,
+ blobURI: uri,
encryptionKey,
};
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 1:28 AM (14 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2615469
Default Alt Text
D8371.id28256.diff (6 KB)
Attached To
Mode
D8371: [lib] Workaround Flow issues in messages-reducer
Attached
Detach File
Event Timeline
Log In to Comment