Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3570990
D7643.id25926.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
D7643.id25926.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
@@ -13,7 +13,6 @@
filenameFromPathOrURI,
} from 'lib/media/file-utils.js';
import type { ImageAvatarDBContent } from 'lib/types/avatar-types.js';
-import type { SetState } from 'lib/types/hook-types.js';
import type {
NativeMediaSelection,
MediaLibrarySelection,
@@ -114,7 +113,7 @@
}
function useUploadSelectedMedia(
- setProcessingOrUploadInProgress: SetState<boolean>,
+ setProcessingOrUploadInProgress: (inProgress: boolean) => void,
): (selection: NativeMediaSelection) => Promise<?ImageAvatarDBContent> {
const processSelectedMedia = useProcessSelectedMedia();
const uploadProcessedMedia = useUploadProcessedMedia();
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
@@ -53,15 +53,31 @@
const dispatchActionPromise = useDispatchActionPromise();
const changeThreadSettingsCall = useServerCall(changeThreadSettings);
- const [processingOrUploadInProgress, setProcessingOrUploadInProgress] =
- React.useState(false);
+ const [
+ threadAvatarMediaUploadInProgress,
+ setThreadAvatarMediaUploadInProgress,
+ ] = React.useState<$ReadOnlySet<string>>(new Set<string>());
+
+ const updateThreadAvatarMediaUploadInProgress = React.useCallback(
+ (inProgress: boolean) =>
+ setThreadAvatarMediaUploadInProgress(prevState => {
+ const updatedSet = new Set(prevState);
+ if (inProgress) {
+ updatedSet.add(activeThreadID);
+ } else {
+ updatedSet.delete(activeThreadID);
+ }
+ return updatedSet;
+ }),
+ [activeThreadID],
+ );
const threadAvatarSaveInProgress =
- processingOrUploadInProgress ||
+ threadAvatarMediaUploadInProgress.has(activeThreadID) ||
updateThreadAvatarLoadingStatus === 'loading';
const uploadSelectedMedia = useUploadSelectedMedia(
- setProcessingOrUploadInProgress,
+ updateThreadAvatarMediaUploadInProgress,
);
const selectFromGalleryAndUpdateThreadAvatar = React.useCallback(
@@ -88,7 +104,7 @@
dispatchActionPromise(
changeThreadSettingsActionTypes,
(async () => {
- setProcessingOrUploadInProgress(false);
+ updateThreadAvatarMediaUploadInProgress(false);
try {
return await changeThreadSettingsCall(updateThreadRequest);
} catch (e) {
@@ -101,7 +117,12 @@
},
);
},
- [changeThreadSettingsCall, dispatchActionPromise, uploadSelectedMedia],
+ [
+ changeThreadSettingsCall,
+ dispatchActionPromise,
+ updateThreadAvatarMediaUploadInProgress,
+ uploadSelectedMedia,
+ ],
);
const removeThreadAvatar = React.useCallback(
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
@@ -57,8 +57,13 @@
userAvatarMediaUploadInProgress ||
updateUserAvatarLoadingStatus === 'loading';
+ const updateUserAvatarMediaUploadInProgress = React.useCallback(
+ (inProgress: boolean) => setUserAvatarMediaUploadInProgress(inProgress),
+ [],
+ );
+
const uploadSelectedMedia = useUploadSelectedMedia(
- setUserAvatarMediaUploadInProgress,
+ updateUserAvatarMediaUploadInProgress,
);
const updateImageUserAvatar = React.useCallback(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 29, 6:55 AM (8 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2731133
Default Alt Text
D7643.id25926.diff (3 KB)
Attached To
Mode
D7643: [native] have upload thread avatar processing/uploading loader only appear for thread being updated
Attached
Detach File
Event Timeline
Log In to Comment