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 @@ -128,12 +128,12 @@ function useUploadSelectedMedia( setProcessingOrUploadInProgress: SetState, -): (selection: ?NativeMediaSelection) => Promise { +): (selection: NativeMediaSelection) => Promise { const processSelectedMedia = useProcessSelectedMedia(); const uploadProcessedMedia = useUploadProcessedMedia(); return React.useCallback( - async (selection: ?NativeMediaSelection) => { + async (selection: NativeMediaSelection) => { if (!selection) { Alert.alert( 'Media selection failed', @@ -224,6 +224,9 @@ const selectFromGalleryAndUpdateThreadAvatar = React.useCallback(async () => { const selection: ?MediaLibrarySelection = await selectFromGallery(); + if (!selection) { + return; + } const imageAvatarUpdateRequest = await uploadSelectedMedia(selection); diff --git a/native/avatars/edit-user-avatar-provider.react.js b/native/avatars/edit-user-avatar-provider.react.js --- a/native/avatars/edit-user-avatar-provider.react.js +++ b/native/avatars/edit-user-avatar-provider.react.js @@ -62,7 +62,7 @@ ); const updateImageUserAvatar = React.useCallback( - async (selection: ?NativeMediaSelection) => { + async (selection: NativeMediaSelection) => { const imageAvatarUpdateRequest = await uploadSelectedMedia(selection); if (!imageAvatarUpdateRequest) { @@ -87,6 +87,9 @@ const selectFromGalleryAndUpdateUserAvatar = React.useCallback(async () => { const selection = await selectFromGallery(); + if (!selection) { + return; + } await updateImageUserAvatar(selection); }, [updateImageUserAvatar]);