Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3033684
D8901.id30289.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
D8901.id30289.diff
View Options
diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js
--- a/lib/selectors/user-selectors.js
+++ b/lib/selectors/user-selectors.js
@@ -8,6 +8,7 @@
getRandomDefaultEmojiAvatar,
} from '../shared/avatar-utils.js';
import SearchIndex from '../shared/search-index.js';
+import SentencePrefixSearchIndex from '../shared/sentence-prefix-search-index.js';
import { getSingleOtherUser } from '../shared/thread-utils.js';
import type { ClientEmojiAvatar } from '../types/avatar-types';
import type { BaseAppState } from '../types/redux-types.js';
@@ -166,22 +167,40 @@
state.dataLoaded
);
+const addUsersToSearchIndex = (
+ userInfos: UserInfos,
+ searchIndex: SearchIndex | SentencePrefixSearchIndex,
+): void => {
+ for (const id in userInfos) {
+ const { username } = userInfos[id];
+ if (!username) {
+ continue;
+ }
+ searchIndex.addEntry(id, username);
+ }
+};
+
const userStoreSearchIndex: (state: BaseAppState<>) => SearchIndex =
createSelector(
(state: BaseAppState<>) => state.userStore.userInfos,
(userInfos: UserInfos) => {
const searchIndex = new SearchIndex();
- for (const id in userInfos) {
- const { username } = userInfos[id];
- if (!username) {
- continue;
- }
- searchIndex.addEntry(id, username);
- }
+ addUsersToSearchIndex(userInfos, searchIndex);
return searchIndex;
},
);
+const userStoreMentionSearchIndex: (
+ state: BaseAppState<>,
+) => SentencePrefixSearchIndex = createSelector(
+ (state: BaseAppState<>) => state.userStore.userInfos,
+ (userInfos: UserInfos) => {
+ const searchIndex = new SentencePrefixSearchIndex();
+ addUsersToSearchIndex(userInfos, searchIndex);
+ return searchIndex;
+ },
+);
+
const usersWithPersonalThreadSelector: (
state: BaseAppState<>,
) => $ReadOnlySet<string> = createSelector(
@@ -230,6 +249,7 @@
userSearchIndexForPotentialMembers,
isLoggedIn,
userStoreSearchIndex,
+ userStoreMentionSearchIndex,
usersWithPersonalThreadSelector,
savedEmojiAvatarSelectorForCurrentUser,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 22, 9:37 PM (19 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2344563
Default Alt Text
D8901.id30289.diff (2 KB)
Attached To
Mode
D8901: [lib] Add userStoreMentionSearchIndex selector
Attached
Detach File
Event Timeline
Log In to Comment