Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3520516
D8363.id29220.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
D8363.id29220.diff
View Options
diff --git a/lib/components/edit-user-avatar-provider.react.js b/lib/components/edit-user-avatar-provider.react.js
--- a/lib/components/edit-user-avatar-provider.react.js
+++ b/lib/components/edit-user-avatar-provider.react.js
@@ -7,10 +7,7 @@
updateUserAvatarActionTypes,
} from '../actions/user-actions.js';
import { createLoadingStatusSelector } from '../selectors/loading-selectors.js';
-import type {
- ImageAvatarDBContent,
- UpdateUserAvatarRequest,
-} from '../types/avatar-types.js';
+import type { UpdateUserAvatarRequest } from '../types/avatar-types.js';
import type { SetState } from '../types/hook-types.js';
import type { LoadingStatus } from '../types/loading-types.js';
import type { NativeMediaSelection } from '../types/media-types.js';
@@ -34,9 +31,6 @@
export type EditUserAvatarContextType = {
+setUserAvatarMediaUploadInProgress: SetState<boolean>,
+userAvatarSaveInProgress: boolean,
- +baseUpdateImageUserAvatar: (
- imageAvatarUpdateRequest: ImageAvatarDBContent,
- ) => Promise<void>,
+baseSetUserAvatar: (avatarRequest: UpdateUserAvatarRequest) => Promise<void>,
+setRegistrationMode: (registrationMode: RegistrationMode) => void,
+getRegistrationModeEnabled: () => boolean,
@@ -73,25 +67,16 @@
userAvatarMediaUploadInProgress ||
updateUserAvatarLoadingStatus === 'loading';
- // NOTE: Do **NOT** consume `baseUpdateImageUserAvatar` directly.
- // Use platform-specific `[web/native]UpdateImageUserAvatar` instead.
- const baseUpdateImageUserAvatar = React.useCallback(
- async (imageAvatarUpdateRequest: ImageAvatarDBContent) => {
- const promise = (async () => {
- setUserAvatarMediaUploadInProgress(false);
- return await updateUserAvatarCall(imageAvatarUpdateRequest);
- })();
- dispatchActionPromise(updateUserAvatarActionTypes, promise);
- await promise;
- },
- [dispatchActionPromise, updateUserAvatarCall],
- );
-
// NOTE: Do **NOT** consume `baseSetUserAvatar` directly.
// Use platform-specific `[web/native]SetUserAvatar` instead.
const baseSetUserAvatar = React.useCallback(
async (request: UpdateUserAvatarRequest) => {
- const promise = updateUserAvatarCall(request);
+ const promise = (async () => {
+ if (request.type === 'image') {
+ setUserAvatarMediaUploadInProgress(false);
+ }
+ return await updateUserAvatarCall(request);
+ })();
dispatchActionPromise(updateUserAvatarActionTypes, promise);
await promise;
},
@@ -117,7 +102,6 @@
() => ({
setUserAvatarMediaUploadInProgress,
userAvatarSaveInProgress,
- baseUpdateImageUserAvatar,
baseSetUserAvatar,
setRegistrationMode,
getRegistrationModeEnabled,
@@ -126,7 +110,6 @@
[
setUserAvatarMediaUploadInProgress,
userAvatarSaveInProgress,
- baseUpdateImageUserAvatar,
baseSetUserAvatar,
setRegistrationMode,
getRegistrationModeEnabled,
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
@@ -244,7 +244,7 @@
const editUserAvatarContext = React.useContext(EditUserAvatarContext);
invariant(editUserAvatarContext, 'editUserAvatarContext must be defined');
const {
- baseUpdateImageUserAvatar,
+ baseSetUserAvatar,
getRegistrationModeEnabled,
getRegistrationModeSuccessCallback,
setUserAvatarMediaUploadInProgress,
@@ -276,7 +276,7 @@
}
try {
- await baseUpdateImageUserAvatar(imageAvatarUpdateRequest);
+ await baseSetUserAvatar(imageAvatarUpdateRequest);
} catch {
displayAvatarUpdateFailureAlert();
}
@@ -284,7 +284,7 @@
[
getRegistrationModeEnabled,
getRegistrationModeSuccessCallback,
- baseUpdateImageUserAvatar,
+ baseSetUserAvatar,
uploadSelectedMedia,
],
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 12:39 AM (18 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2696049
Default Alt Text
D8363.id29220.diff (3 KB)
Attached To
Mode
D8363: [lib] Consolidate `baseUpdateImageUserAvatar` into `baseSetUserAvatar`
Attached
Detach File
Event Timeline
Log In to Comment