Page MenuHomePhabricator

D8020.diff
No OneTemporary

D8020.diff

diff --git a/native/avatars/edit-thread-avatar-provider.react.js b/native/avatars/edit-thread-avatar-provider.react.js
--- a/native/avatars/edit-thread-avatar-provider.react.js
+++ b/native/avatars/edit-thread-avatar-provider.react.js
@@ -8,7 +8,7 @@
changeThreadSettingsActionTypes,
} from 'lib/actions/thread-actions.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
-import type { UpdateUserAvatarRemoveRequest } from 'lib/types/avatar-types.js';
+import type { UpdateUserAvatarRequest } from 'lib/types/avatar-types.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type {
MediaLibrarySelection,
@@ -32,7 +32,10 @@
selection: NativeMediaSelection,
threadID: string,
) => Promise<void>,
- +removeThreadAvatar: (threadID: string) => void,
+ +setThreadAvatar: (
+ threadID: string,
+ avatarRequest: UpdateUserAvatarRequest,
+ ) => Promise<void>,
};
const EditThreadAvatarContext: React.Context<?EditThreadAvatarContextType> =
@@ -138,32 +141,27 @@
[updateImageThreadAvatar],
);
- const removeThreadAvatar = React.useCallback(
- (threadID: string) => {
- const removeAvatarRequest: UpdateUserAvatarRemoveRequest = {
- type: 'remove',
- };
-
+ const setThreadAvatar = React.useCallback(
+ async (threadID: string, avatarRequest: UpdateUserAvatarRequest) => {
const updateThreadRequest: UpdateThreadRequest = {
threadID,
changes: {
- avatar: removeAvatarRequest,
+ avatar: avatarRequest,
},
};
-
const action = changeThreadSettingsActionTypes.started;
- dispatchActionPromise(
- changeThreadSettingsActionTypes,
- (async () => {
- try {
- return await changeThreadSettingsCall(updateThreadRequest);
- } catch (e) {
- Alert.alert('Avatar update failed', 'Unable to update avatar.');
- throw e;
- }
- })(),
- { customKeyName: `${action}:${threadID}:avatar` },
- );
+ const promise = (async () => {
+ try {
+ return await changeThreadSettingsCall(updateThreadRequest);
+ } catch (e) {
+ Alert.alert('Avatar update failed', 'Unable to update avatar.');
+ throw e;
+ }
+ })();
+ dispatchActionPromise(changeThreadSettingsActionTypes, promise, {
+ customKeyName: `${action}:${threadID}:avatar`,
+ });
+ await promise;
},
[changeThreadSettingsCall, dispatchActionPromise],
);
@@ -173,13 +171,13 @@
threadAvatarSaveInProgress,
selectFromGalleryAndUpdateThreadAvatar,
updateImageThreadAvatar,
- removeThreadAvatar,
+ setThreadAvatar,
}),
[
- removeThreadAvatar,
+ threadAvatarSaveInProgress,
selectFromGalleryAndUpdateThreadAvatar,
updateImageThreadAvatar,
- threadAvatarSaveInProgress,
+ setThreadAvatar,
],
);
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
@@ -30,7 +30,7 @@
const {
threadAvatarSaveInProgress,
selectFromGalleryAndUpdateThreadAvatar,
- removeThreadAvatar,
+ setThreadAvatar,
} = editThreadAvatarContext;
const { navigate } = useNavigation();
@@ -58,8 +58,8 @@
}, [navigate, threadInfo.id]);
const removeAvatar = React.useCallback(
- () => removeThreadAvatar(threadInfo.id),
- [removeThreadAvatar, threadInfo.id],
+ () => setThreadAvatar(threadInfo.id, { type: 'remove' }),
+ [setThreadAvatar, threadInfo.id],
);
const actionSheetConfig = React.useMemo(() => {

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 4, 11:51 AM (10 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2614181
Default Alt Text
D8020.diff (3 KB)

Event Timeline