Page MenuHomePhabricator

D4269.diff
No OneTemporary

D4269.diff

diff --git a/web/settings/relationship/add-users-list.react.js b/web/settings/relationship/add-users-list.react.js
--- a/web/settings/relationship/add-users-list.react.js
+++ b/web/settings/relationship/add-users-list.react.js
@@ -17,7 +17,6 @@
const { searchText } = props;
const userStoreSearchIndex = useSelector(userStoreSearchIndexSelector);
- // eslint-disable-next-line no-unused-vars
const [userStoreSearchResults, setUserStoreSearchResults] = React.useState<
$ReadOnlySet<string>,
>(new Set(userStoreSearchIndex.getSearchResults(searchText)));
@@ -27,7 +26,6 @@
);
}, [searchText, userStoreSearchIndex]);
- // eslint-disable-next-line no-unused-vars
const [serverSearchResults, setServerSearchResults] = React.useState<
$ReadOnlyArray<GlobalAccountUserInfo>,
>([]);
@@ -43,6 +41,34 @@
})();
}, [callSearchUsers, searchText]);
+ const searchTextPresent = searchText.length > 0;
+ const userInfos = useSelector(state => state.userStore.userInfos);
+ // eslint-disable-next-line no-unused-vars
+ const mergedUserInfos = React.useMemo(() => {
+ const mergedInfos = {};
+
+ for (const userInfo of serverSearchResults) {
+ mergedInfos[userInfo.id] = userInfo;
+ }
+
+ const userStoreUserIDs = searchTextPresent
+ ? userStoreSearchResults
+ : Object.keys(userInfos);
+ for (const id of userStoreUserIDs) {
+ const { username, relationshipStatus } = userInfos[id];
+ if (username) {
+ mergedInfos[id] = { id, username, relationshipStatus };
+ }
+ }
+
+ return mergedInfos;
+ }, [
+ searchTextPresent,
+ serverSearchResults,
+ userInfos,
+ userStoreSearchResults,
+ ]);
+
return null;
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 10:10 AM (21 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2676713
Default Alt Text
D4269.diff (1 KB)

Event Timeline