Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3404587
D8020.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8020.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D8020: [native] Replace removeThreadAvatar with generic setThreadAvatar
Attached
Detach File
Event Timeline
Log In to Comment