Page MenuHomePhabricator

D7643.id25943.diff
No OneTemporary

D7643.id25943.diff

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(

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 29, 6:25 AM (7 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2730989
Default Alt Text
D7643.id25943.diff (2 KB)

Event Timeline