diff --git a/native/avatars/avatar-hooks.js b/native/avatars/avatar-hooks.js --- a/native/avatars/avatar-hooks.js +++ b/native/avatars/avatar-hooks.js @@ -25,6 +25,11 @@ MediaLibrarySelection, MediaMissionFailure, } from 'lib/types/media-types.js'; +import type { + RawThreadInfo, + ThreadInfo, +} from 'lib/types/minimally-encoded-thread-permissions-types.js'; +import { threadTypeIsThick } from 'lib/types/thread-types-enum.js'; import { authoritativeKeyserverID } from '../authoritative-keyserver.js'; import CommIcon from '../components/comm-icon.react.js'; @@ -409,7 +414,7 @@ function useNativeUpdateThreadImageAvatar(): ( selection: NativeMediaSelection, - threadID: string, + threadInfo: ThreadInfo | RawThreadInfo, ) => Promise { const editThreadAvatarContext = React.useContext(EditThreadAvatarContext); invariant(editThreadAvatarContext, 'editThreadAvatarContext must be defined'); @@ -423,18 +428,21 @@ const nativeUpdateThreadImageAvatar = React.useCallback( async ( selection: NativeMediaSelection, - threadID: string, + threadInfo: ThreadInfo | RawThreadInfo, ): Promise => { + const shouldUploadMetadataToKeyserver = !threadTypeIsThick( + threadInfo.type, + ); const imageAvatarUpdateRequest = await uploadSelectedMedia( selection, - true, + shouldUploadMetadataToKeyserver, ); if (!imageAvatarUpdateRequest) { return; } try { - await baseSetThreadAvatar(threadID, imageAvatarUpdateRequest); + await baseSetThreadAvatar(threadInfo.id, imageAvatarUpdateRequest); } catch { displayAvatarUpdateFailureAlert(); } @@ -446,17 +454,17 @@ } function useSelectFromGalleryAndUpdateThreadAvatar(): ( - threadID: string, + threadInfo: ThreadInfo | RawThreadInfo, ) => Promise { const nativeUpdateThreadImageAvatar = useNativeUpdateThreadImageAvatar(); const selectFromGalleryAndUpdateThreadAvatar = React.useCallback( - async (threadID: string): Promise => { + async (threadInfo: ThreadInfo | RawThreadInfo): Promise => { const selection: ?MediaLibrarySelection = await selectFromGallery(); if (!selection) { return; } - await nativeUpdateThreadImageAvatar(selection, threadID); + await nativeUpdateThreadImageAvatar(selection, threadInfo); }, [nativeUpdateThreadImageAvatar], ); diff --git a/native/avatars/edit-thread-avatar.react.js b/native/avatars/edit-thread-avatar.react.js --- a/native/avatars/edit-thread-avatar.react.js +++ b/native/avatars/edit-thread-avatar.react.js @@ -53,8 +53,8 @@ }, [navigate, threadInfo]); const selectFromGallery = React.useCallback( - () => selectFromGalleryAndUpdateThreadAvatar(threadInfo.id), - [selectFromGalleryAndUpdateThreadAvatar, threadInfo.id], + () => selectFromGalleryAndUpdateThreadAvatar(threadInfo), + [selectFromGalleryAndUpdateThreadAvatar, threadInfo], ); const navigateToCamera = React.useCallback(() => { diff --git a/native/media/thread-avatar-camera-modal.react.js b/native/media/thread-avatar-camera-modal.react.js --- a/native/media/thread-avatar-camera-modal.react.js +++ b/native/media/thread-avatar-camera-modal.react.js @@ -35,8 +35,8 @@ const sendPhoto = React.useCallback( (capture: PhotoCapture) => - nativeUpdateThreadImageAvatar(capture, threadInfo.id), - [threadInfo.id, nativeUpdateThreadImageAvatar], + nativeUpdateThreadImageAvatar(capture, threadInfo), + [threadInfo, nativeUpdateThreadImageAvatar], ); return ;