Page MenuHomePhabricator

D9668.id33052.diff
No OneTemporary

D9668.id33052.diff

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 (
- <View style={[containerSizeStyle, styles.imageContainer]}>
- <Multimedia mediaInfo={avatarMediaInfo} spinnerColor="white" />
+ <View style={emojiContainerStyle}>
+ <Text style={emojiSizeStyle}>{avatarInfo.emoji}</Text>
</View>
);
}
+ let avatarMediaInfo;
+ if (avatarInfo.type === 'encrypted_image') {
+ avatarMediaInfo = avatarInfo;
+ } else if (avatarInfo.type === 'image') {
+ avatarMediaInfo = {
+ type: 'photo',
+ uri: avatarInfo.uri,
+ };
+ } else {
+ return null;
+ }
+
return (
- <View style={emojiContainerStyle}>
- <Text style={emojiSizeStyle}>{avatarInfo.emoji}</Text>
+ <View style={[containerSizeStyle, styles.imageContainer]}>
+ <Multimedia mediaInfo={avatarMediaInfo} spinnerColor="white" />
</View>
);
- }, [
- 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');
}

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 6:48 AM (19 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2860864
Default Alt Text
D9668.id33052.diff (2 KB)

Event Timeline