Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3731711
D10200.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D10200.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
@@ -1295,21 +1295,57 @@
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 });
+ if (singleMedia.blobURI) {
+ const { holder, ...rest } = mediaUpdate;
+ if (holder) {
+ console.log(
+ `mediaUpdate contained holder for media ${singleMedia.id} ` +
+ 'that has blobURI',
+ );
+ }
+ media.push({ ...singleMedia, ...rest });
+ } else {
+ invariant(
+ singleMedia.holder,
+ 'Encrypted media must have holder or blobURI',
+ );
+ const { blobURI, ...rest } = mediaUpdate;
+ if (blobURI) {
+ console.log(
+ `mediaUpdate contained blobURI for media ${singleMedia.id} ` +
+ 'that has holder',
+ );
+ }
+ media.push({ ...singleMedia, ...rest });
+ }
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 });
+ if (singleMedia.blobURI) {
+ const { holder, thumbnailHolder, ...rest } = mediaUpdate;
+ if (holder || thumbnailHolder) {
+ console.log(
+ 'mediaUpdate contained holder or thumbnailHolder for media ' +
+ `${singleMedia.id} that has blobURI`,
+ );
+ }
+ media.push({ ...singleMedia, ...rest });
+ } else {
+ invariant(
+ singleMedia.holder,
+ 'Encrypted media must have holder or blobURI',
+ );
+ const { blobURI, thumbnailBlobURI, ...rest } = mediaUpdate;
+ if (blobURI || thumbnailBlobURI) {
+ console.log(
+ 'mediaUpdate contained blobURI or thumbnailBlobURI for media ' +
+ `${singleMedia.id} that has holder`,
+ );
+ }
+ media.push({ ...singleMedia, ...rest });
+ }
replaced = true;
} else if (
singleMedia.type === 'photo' &&
@@ -1374,34 +1410,7 @@
replaced = true;
} else if (mediaUpdate.id) {
const { id: newID } = mediaUpdate;
- // branching for Flow
- if (singleMedia.type === 'photo') {
- media.push({ ...singleMedia, id: newID });
- } else if (singleMedia.type === 'video') {
- media.push({ ...singleMedia, id: newID });
- } else if (singleMedia.type === 'encrypted_photo') {
- // 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') {
- // 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 });
- }
- }
+ media.push({ ...singleMedia, id: newID });
replaced = true;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 1:01 AM (13 h, 33 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2842481
Default Alt Text
D10200.diff (4 KB)
Attached To
Mode
D10200: [lib] Remove $FlowFixMes in message-reducer.js
Attached
Detach File
Event Timeline
Log In to Comment