diff --git a/lib/types/avatar-types.js b/lib/types/avatar-types.js --- a/lib/types/avatar-types.js +++ b/lib/types/avatar-types.js @@ -24,6 +24,11 @@ +uploadID: string, }; +export type EncryptedImageAvatarDBContent = { + +type: 'encrypted-image', + +uploadID: string, +}; + export type ENSAvatarDBContent = { +type: 'ens', }; @@ -33,6 +38,7 @@ export type AvatarDBContent = | EmojiAvatarDBContent | ImageAvatarDBContent + | EncryptedImageAvatarDBContent | ENSAvatarDBContent; export type UpdateUserAvatarRemoveRequest = { +type: 'remove' }; @@ -53,12 +59,20 @@ uri: t.String, }); +export type ClientEncryptedImageAvatar = { + +type: 'encrypted-image', + +blobURI: string, + +encryptionKey: string, + +thumbHash: ?string, +}; + export type ClientENSAvatar = ENSAvatarDBContent; const clientENSAvatarValidator = ensAvatarDBContentValidator; export type ClientAvatar = | ClientEmojiAvatar | ClientImageAvatar + | ClientEncryptedImageAvatar | ClientENSAvatar; export const clientAvatarValidator: TUnion = t.union([ clientEmojiAvatarValidator, @@ -66,7 +80,10 @@ clientENSAvatarValidator, ]); -export type ResolvedClientAvatar = ClientEmojiAvatar | ClientImageAvatar; +export type ResolvedClientAvatar = + | ClientEmojiAvatar + | ClientImageAvatar + | ClientEncryptedImageAvatar; export type UpdateUserAvatarResponse = { +updates: CreateUpdatesResult, diff --git a/native/account/registration/avatar-selection.react.js b/native/account/registration/avatar-selection.react.js --- a/native/account/registration/avatar-selection.react.js +++ b/native/account/registration/avatar-selection.react.js @@ -91,7 +91,8 @@ } else if (selection.updateUserAvatarRequest.type !== 'remove') { const clientRequest = selection.updateUserAvatarRequest; invariant( - clientRequest.type !== 'image', + clientRequest.type !== 'image' && + clientRequest.type !== 'encrypted-image', 'image avatars need to be uploaded', ); const newAvatarData = {