Page MenuHomePhabricator

D8901.id30185.diff
No OneTemporary

D8901.id30185.diff

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

Mime Type
text/plain
Expires
Tue, Oct 22, 9:38 PM (20 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2344563
Default Alt Text
D8901.id30185.diff (2 KB)

Event Timeline