Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3183668
D7638.id25907.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7638.id25907.diff
View Options
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<boolean>,
-): (selection: ?NativeMediaSelection) => Promise<?ImageAvatarDBContent> {
+): (selection: NativeMediaSelection) => Promise<?ImageAvatarDBContent> {
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) {
@@ -86,7 +86,10 @@
);
const selectFromGalleryAndUpdateUserAvatar = React.useCallback(async () => {
- const selection = await selectFromGallery();
+ const selection: ?NativeMediaSelection = await selectFromGallery();
+ if (!selection) {
+ return;
+ }
await updateImageUserAvatar(selection);
}, [updateImageUserAvatar]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 9:51 AM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2451253
Default Alt Text
D7638.id25907.diff (1 KB)
Attached To
Mode
D7638: [native] Return without error if avatar image `selection` is empty
Attached
Detach File
Event Timeline
Log In to Comment