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'; @@ -407,7 +412,7 @@ function useNativeUpdateThreadImageAvatar(): ( selection: NativeMediaSelection, - threadID: string, + threadInfo: ThreadInfo | RawThreadInfo, ) => Promise { const editThreadAvatarContext = React.useContext(EditThreadAvatarContext); invariant(editThreadAvatarContext, 'editThreadAvatarContext must be defined'); @@ -421,18 +426,21 @@ const nativeUpdateThreadImageAvatar = React.useCallback( async ( selection: NativeMediaSelection, - threadID: string, + threadInfo: ThreadInfo | RawThreadInfo, ): Promise => { + const metadataUploadLocation = threadTypeIsThick(threadInfo.type) + ? 'none' + : 'keyserver'; const imageAvatarUpdateRequest = await uploadSelectedMedia( selection, - 'keyserver', + metadataUploadLocation, ); if (!imageAvatarUpdateRequest) { return; } try { - await baseSetThreadAvatar(threadID, imageAvatarUpdateRequest); + await baseSetThreadAvatar(threadInfo.id, imageAvatarUpdateRequest); } catch { displayAvatarUpdateFailureAlert(); } @@ -444,17 +452,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 ;