Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3509205
D6479.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
D6479.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D6479: [lib] Inline threadSearchText
Attached
Detach File
Event Timeline
Log In to Comment