-
-
Save Ashoat/d83301775bc01c7f71af3350ce440dbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js | |
index dde305253..5533d1377 100644 | |
--- a/lib/reducers/message-reducer.js | |
+++ b/lib/reducers/message-reducer.js | |
@@ -1374,12 +1374,8 @@ function reduceMessageStore( | |
const { | |
messageID: id, | |
currentMediaID, | |
- mediaUpdate: _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( | |
@@ -1445,12 +1441,20 @@ function reduceMessageStore( | |
singleMedia.type === 'encrypted_photo' && | |
mediaUpdate.type === 'encrypted_photo' | |
) { | |
+ // TODO: Remove this any-cast after RN 0.72 / Flow 0.202 update | |
+ // 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 any-cast after RN 0.72 / Flow 0.202 update | |
+ // 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 ( | |
@@ -1521,13 +1525,19 @@ function reduceMessageStore( | |
media.push({ ...singleMedia, id: newID }); | |
} else if (singleMedia.type === 'video') { | |
media.push({ ...singleMedia, id: newID }); | |
+ } else if (singleMedia.type === 'encrypted_photo' && singleMedia.holder) { | |
+ // TODO: branch may be removable after RN 0.72 / Flow 0.202 update | |
+ media.push({ ...singleMedia, id: newID }); | |
+ } else if (singleMedia.type === 'encrypted_photo') { | |
+ invariant(singleMedia.blobURI, ''); | |
+ 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' && singleMedia.holder) { | |
+ // TODO: branch may be removable after RN 0.72 / Flow 0.202 update | |
media.push({ ...singleMedia, id: newID }); | |
} else if (singleMedia.type === 'encrypted_video') { | |
- // TODO: This should work after RN 0.72 / Flow 0.202 update | |
- // $FlowFixMe | |
+ invariant(singleMedia.blobURI, ''); | |
media.push({ ...singleMedia, id: newID }); | |
} | |
replaced = true; | |
diff --git a/lib/reducers/message-reducer.test.js b/lib/reducers/message-reducer.test.js | |
index 799fdf35e..3a270c791 100644 | |
--- a/lib/reducers/message-reducer.test.js | |
+++ b/lib/reducers/message-reducer.test.js | |
@@ -66,8 +66,6 @@ describe('UPDATE_MULTIMEDIA_MESSAGE_MEDIA', () => { | |
}; | |
const { messageStore: updatedMessageStore } = reduceMessageStore( | |
messageStoreBeforeMediaUpdate, | |
- // TODO: This should work after RN 0.72 / Flow 0.202 update | |
- // $FlowFixMe | |
updateMultiMediaMessageMediaAction, | |
{}, | |
); | |
@@ -123,8 +121,6 @@ describe('UPDATE_MULTIMEDIA_MESSAGE_MEDIA', () => { | |
const { messageStore: storeWithoutLocalMediaSelectionUpdate } = | |
reduceMessageStore( | |
messageStoreBeforeMediaUpdate, | |
- // TODO: This should work after RN 0.72 / Flow 0.202 update | |
- // $FlowFixMe | |
actionWithoutLocalMediaSelectionUpdate, | |
{}, | |
); | |
diff --git a/lib/types/media-types.js b/lib/types/media-types.js | |
index 91c2538e7..627f75b1c 100644 | |
--- a/lib/types/media-types.js | |
+++ b/lib/types/media-types.js | |
@@ -77,7 +77,7 @@ export const uploadMultimediaResultValidator: TInterface<UploadMultimediaResult> | |
export type UpdateMultimediaMessageMediaPayload = { | |
+messageID: string, | |
+currentMediaID: string, | |
- +mediaUpdate: Shape<Media>, | |
+ +mediaUpdate: MediaShape, | |
}; | |
export type UploadDeletionRequest = { | |
@@ -767,6 +767,7 @@ export const encryptedVideoValidator: TUnion<EncryptedVideo> = | |
]); | |
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, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment