Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3488486
D4269.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4269.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D4269: [web] Merge store and server search results
Attached
Detach File
Event Timeline
Log In to Comment