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,33 @@ 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; + media.push({ ...singleMedia, ...rest }); + } else { + invariant( + singleMedia.holder, + 'Encrypted media must have holder or blobURI', + ); + const { blobURI: _, ...rest } = mediaUpdate; + 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: _1, thumbnailHolder: _2, ...rest } = mediaUpdate; + media.push({ ...singleMedia, ...rest }); + } else { + invariant( + singleMedia.holder, + 'Encrypted media must have holder or blobURI', + ); + const { blobURI: _1, thumbnailBlobURI: _2, ...rest } = mediaUpdate; + media.push({ ...singleMedia, ...rest }); + } replaced = true; } else if ( singleMedia.type === 'photo' && @@ -1374,34 +1386,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; } }