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 @@ -2,6 +2,7 @@ import t, { type TInterface, type TUnion } from 'tcomb'; +import type { ClientEncryptedImageAvatar } from './avatar-types'; import type { Shape } from './core.js'; import { type Platform } from './device-types.js'; import { tShape, tString, tID } from '../utils/validation-utils.js'; @@ -21,10 +22,12 @@ export type EncryptedMediaType = 'encrypted_photo' | 'encrypted_video'; -export type AvatarMediaInfo = { - +type: 'photo', - +uri: string, -}; +export type AvatarMediaInfo = + | ClientEncryptedImageAvatar + | { + +type: 'photo', + +uri: string, + }; export type ClientDBMediaInfo = { +id: string, diff --git a/native/avatars/avatar.react.js b/native/avatars/avatar.react.js --- a/native/avatars/avatar.react.js +++ b/native/avatars/avatar.react.js @@ -67,32 +67,32 @@ }, [size]); const avatar = React.useMemo(() => { - if (avatarInfo.type === 'image') { - const avatarMediaInfo = { - type: 'photo', - uri: avatarInfo.uri, - }; - + if (avatarInfo.type !== 'image' && avatarInfo.type !== 'encrypted_image') { return ( - - + + {avatarInfo.emoji} ); } + let avatarMediaInfo; + if (avatarInfo.type === 'encrypted_image') { + avatarMediaInfo = avatarInfo; + } else if (avatarInfo.type === 'image') { + avatarMediaInfo = { + type: 'photo', + uri: avatarInfo.uri, + }; + } else { + return null; + } + return ( - - {avatarInfo.emoji} + + ); - }, [ - avatarInfo.emoji, - avatarInfo.type, - avatarInfo.uri, - containerSizeStyle, - emojiContainerStyle, - emojiSizeStyle, - ]); + }, [avatarInfo, containerSizeStyle, emojiContainerStyle, emojiSizeStyle]); return avatar; } diff --git a/native/media/multimedia.react.js b/native/media/multimedia.react.js --- a/native/media/multimedia.react.js +++ b/native/media/multimedia.react.js @@ -203,6 +203,14 @@ encryptionKey: mediaInfo.thumbnailEncryptionKey, thumbHash: mediaInfo.thumbnailThumbHash, }; + } else if (mediaInfo.type === 'encrypted_image') { + const { blobURI, encryptionKey, thumbHash } = mediaInfo; + return { + kind: 'encrypted', + blobURI, + encryptionKey, + thumbHash, + }; } else { invariant(false, 'Invalid mediaInfo type'); }