Page MenuHomePhabricator

D6479.diff
No OneTemporary

D6479.diff

diff --git a/lib/selectors/nav-selectors.js b/lib/selectors/nav-selectors.js
--- a/lib/selectors/nav-selectors.js
+++ b/lib/selectors/nav-selectors.js
@@ -4,7 +4,7 @@
import { createSelector } from 'reselect';
import SearchIndex from '../shared/search-index';
-import { threadSearchText } from '../shared/thread-utils';
+import { memberHasAdminPowers } from '../shared/thread-utils';
import type { Platform } from '../types/device-types';
import { type CalendarQuery, defaultCalendarQuery } from '../types/entry-types';
import type { CalendarFilter } from '../types/filter-types';
@@ -77,10 +77,27 @@
return React.useMemo(() => {
const searchIndex = new SearchIndex();
for (const threadInfo of threadInfos) {
- searchIndex.addEntry(
- threadInfo.id,
- threadSearchText(threadInfo, userInfos, viewerID),
- );
+ const searchTextArray = [];
+ if (threadInfo.name) {
+ searchTextArray.push(threadInfo.name);
+ }
+ if (threadInfo.description) {
+ searchTextArray.push(threadInfo.description);
+ }
+ for (const member of threadInfo.members) {
+ const isParentAdmin = memberHasAdminPowers(member);
+ if (!member.role && !isParentAdmin) {
+ continue;
+ }
+ if (member.id === viewerID) {
+ continue;
+ }
+ const userInfo = userInfos[member.id];
+ if (userInfo && userInfo.username) {
+ searchTextArray.push(userInfo.username);
+ }
+ }
+ searchIndex.addEntry(threadInfo.id, searchTextArray.join(' '));
}
return searchIndex;
}, [threadInfos, userInfos, viewerID]);
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -938,34 +938,6 @@
`contribute to your unread count.\n\n` +
`To move a chat over here, switch the “Background” option in its settings.`;
-const threadSearchText = (
- threadInfo: RawThreadInfo | ThreadInfo,
- userInfos: UserInfos,
- viewerID: ?string,
-): string => {
- const searchTextArray = [];
- if (threadInfo.name) {
- searchTextArray.push(threadInfo.name);
- }
- if (threadInfo.description) {
- searchTextArray.push(threadInfo.description);
- }
- for (const member of threadInfo.members) {
- const isParentAdmin = memberHasAdminPowers(member);
- if (!member.role && !isParentAdmin) {
- continue;
- }
- if (member.id === viewerID) {
- continue;
- }
- const userInfo = userInfos[member.id];
- if (userInfo && userInfo.username) {
- searchTextArray.push(userInfo.username);
- }
- }
- return searchTextArray.join(' ');
-};
-
function threadNoun(threadType: ThreadType): string {
return threadType === threadTypes.SIDEBAR ? 'thread' : 'chat';
}
@@ -1439,7 +1411,6 @@
identifyInvalidatedThreads,
permissionsDisabledByBlock,
emptyItemText,
- threadSearchText,
threadNoun,
threadLabel,
useWatchThread,

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 2:24 AM (15 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690210
Default Alt Text
D6479.diff (2 KB)

Event Timeline