Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3734214
D8774.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D8774.diff
View Options
diff --git a/lib/components/base-edit-thread-avatar-provider.react.js b/lib/components/base-edit-thread-avatar-provider.react.js
--- a/lib/components/base-edit-thread-avatar-provider.react.js
+++ b/lib/components/base-edit-thread-avatar-provider.react.js
@@ -7,10 +7,7 @@
changeThreadSettingsActionTypes,
} from '../actions/thread-actions.js';
import { createLoadingStatusSelector } from '../selectors/loading-selectors.js';
-import type {
- UpdateUserAvatarRequest,
- ImageAvatarDBContent,
-} from '../types/avatar-types.js';
+import type { UpdateUserAvatarRequest } from '../types/avatar-types.js';
import type { LoadingStatus } from '../types/loading-types.js';
import type { UpdateThreadRequest } from '../types/thread-types.js';
import {
@@ -22,10 +19,6 @@
export type EditThreadAvatarContextType = {
+updateThreadAvatarMediaUploadInProgress: (inProgress: boolean) => void,
+threadAvatarSaveInProgress: boolean,
- +updateImageThreadAvatar: (
- imageAvatarUpdateRequest: ImageAvatarDBContent,
- threadID: string,
- ) => Promise<void>,
+baseSetThreadAvatar: (
threadID: string,
avatarRequest: UpdateUserAvatarRequest,
@@ -75,33 +68,6 @@
threadAvatarMediaUploadInProgress.has(activeThreadID) ||
updateThreadAvatarLoadingStatus === 'loading';
- const updateImageThreadAvatar = React.useCallback(
- async (
- imageAvatarUpdateRequest: ImageAvatarDBContent,
- threadID: string,
- ) => {
- const updateThreadRequest: UpdateThreadRequest = {
- threadID,
- changes: {
- avatar: imageAvatarUpdateRequest,
- },
- };
-
- const action = changeThreadSettingsActionTypes.started;
- updateThreadAvatarMediaUploadInProgress(false);
- const promise = changeThreadSettingsCall(updateThreadRequest);
- dispatchActionPromise(changeThreadSettingsActionTypes, promise, {
- customKeyName: `${action}:${threadID}:avatar`,
- });
- await promise;
- },
- [
- changeThreadSettingsCall,
- dispatchActionPromise,
- updateThreadAvatarMediaUploadInProgress,
- ],
- );
-
// NOTE: Do NOT consume `baseSetThreadAvatar` directly.
// Use platform-specific `[web/native]SetThreadAvatar` instead.
const baseSetThreadAvatar = React.useCallback(
@@ -113,26 +79,31 @@
},
};
const action = changeThreadSettingsActionTypes.started;
+ if (avatarRequest.type === 'image') {
+ updateThreadAvatarMediaUploadInProgress(false);
+ }
const promise = changeThreadSettingsCall(updateThreadRequest);
dispatchActionPromise(changeThreadSettingsActionTypes, promise, {
customKeyName: `${action}:${threadID}:avatar`,
});
await promise;
},
- [changeThreadSettingsCall, dispatchActionPromise],
+ [
+ changeThreadSettingsCall,
+ dispatchActionPromise,
+ updateThreadAvatarMediaUploadInProgress,
+ ],
);
const context = React.useMemo(
() => ({
updateThreadAvatarMediaUploadInProgress,
threadAvatarSaveInProgress,
- updateImageThreadAvatar,
baseSetThreadAvatar,
}),
[
updateThreadAvatarMediaUploadInProgress,
threadAvatarSaveInProgress,
- updateImageThreadAvatar,
baseSetThreadAvatar,
],
);
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
@@ -340,7 +340,7 @@
) => Promise<void> {
const editThreadAvatarContext = React.useContext(EditThreadAvatarContext);
invariant(editThreadAvatarContext, 'editThreadAvatarContext must be defined');
- const { updateImageThreadAvatar, updateThreadAvatarMediaUploadInProgress } =
+ const { baseSetThreadAvatar, updateThreadAvatarMediaUploadInProgress } =
editThreadAvatarContext;
const uploadSelectedMedia = useUploadSelectedMedia(
@@ -358,12 +358,12 @@
}
try {
- await updateImageThreadAvatar(imageAvatarUpdateRequest, threadID);
+ await baseSetThreadAvatar(threadID, imageAvatarUpdateRequest);
} catch {
displayAvatarUpdateFailureAlert();
}
},
- [updateImageThreadAvatar, uploadSelectedMedia],
+ [baseSetThreadAvatar, uploadSelectedMedia],
);
return nativeUpdateThreadImageAvatar;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 3:22 AM (6 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2844268
Default Alt Text
D8774.diff (4 KB)
Attached To
Mode
D8774: [lib] Consolidate `updateImageThreadAvatar` into `baseSetThreadAvatar`
Attached
Detach File
Event Timeline
Log In to Comment