Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3339745
D13632.id44962.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13632.id44962.diff
View Options
diff --git a/native/profile/relationship-list.react.js b/native/profile/relationship-list.react.js
--- a/native/profile/relationship-list.react.js
+++ b/native/profile/relationship-list.react.js
@@ -9,6 +9,7 @@
import { useENSNames } from 'lib/hooks/ens-cache.js';
import { useUpdateRelationships } from 'lib/hooks/relationship-hooks.js';
import { registerFetchKey } from 'lib/reducers/loading-reducer.js';
+import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import { useUserSearchIndex } from 'lib/selectors/nav-selectors.js';
import { userRelationshipsSelector } from 'lib/selectors/relationship-selectors.js';
import { useSearchUsers } from 'lib/shared/search-utils.js';
@@ -82,6 +83,10 @@
const tagDataLabelExtractor = (userInfo: GlobalAccountUserInfo) =>
userInfo.username;
+const loadingStatusSelector = createLoadingStatusSelector(
+ updateRelationshipsActionTypes,
+);
+
type Props = {
+navigation: ProfileNavigationProp<'FriendList' | 'BlockList'>,
+route: NavigationRoute<'FriendList' | 'BlockList'>,
@@ -197,8 +202,11 @@
tagInputRef.current?.focus();
}, []);
+ const updateInProgress = React.useRef(false);
+
const updateRelationships = useUpdateRelationships();
const updateRelationshipsOnServer = React.useCallback(async () => {
+ updateInProgress.current = true;
const action = {
[FriendListRouteName]: relationshipActions.FRIEND,
[BlockListRouteName]: relationshipActions.BLOCK,
@@ -217,6 +225,8 @@
{ cancelable: true, onDismiss: onUnknownErrorAlertAcknowledged },
);
throw e;
+ } finally {
+ updateInProgress.current = false;
}
}, [
routeName,
@@ -228,7 +238,7 @@
const dispatchActionPromise = useDispatchActionPromise();
const noCurrentTags = currentTags.length === 0;
const onPressAdd = React.useCallback(() => {
- if (noCurrentTags) {
+ if (noCurrentTags || updateInProgress.current) {
return;
}
void dispatchActionPromise(
@@ -285,6 +295,7 @@
const { setOptions } = navigation;
const prevNoCurrentTags = React.useRef(noCurrentTags);
+ const loadingStatus = useSelector(loadingStatusSelector);
React.useEffect(() => {
let setSaveButtonDisabled;
if (!prevNoCurrentTags.current && noCurrentTags) {
@@ -301,11 +312,15 @@
<LinkButton
text="Save"
onPress={onPressAdd}
- disabled={setSaveButtonDisabled}
+ disabled={
+ setSaveButtonDisabled ||
+ loadingStatus === 'loading' ||
+ updateInProgress.current
+ }
/>
),
});
- }, [setOptions, noCurrentTags, onPressAdd]);
+ }, [setOptions, noCurrentTags, onPressAdd, loadingStatus]);
const relationships = useSelector(userRelationshipsSelector);
const viewerID = useSelector(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 8:37 PM (16 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2564770
Default Alt Text
D13632.id44962.diff (2 KB)
Attached To
Mode
D13632: [native] Avoid updating relationships before the previous call finished
Attached
Detach File
Event Timeline
Log In to Comment