-
-
Notifications
You must be signed in to change notification settings - Fork 831
Do not filter users post search #9556
Changes from 2 commits
c51b5d5
750299c
29c3be1
1eafd8d
7bc920f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -412,7 +412,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n | |||||||||||||||||||||
) | ||||||||||||||||||||||
return; // bail, does not match query | ||||||||||||||||||||||
} else if (isMemberResult(entry)) { | ||||||||||||||||||||||
if (!entry.query?.some((q) => q.includes(lcQuery))) return; // bail, does not match query | ||||||||||||||||||||||
// Do not filter users | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment needs to say WHY (because we rely on the server to filter DIRECTORY results for us) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate why clientside filtering is done in the first place? I think the spec suggests nothing of the kind, and I think additional validation seems superfluous since the server should be trustworthy enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a copy-pasta, but you'd need to ask whomever wrote it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @HarHarLinks and me investigated it further and found the following: The component has different sources for the users: (1) the results from the user profile endpoint and (2) all users that joined any room that I am in. (1) was already server-side filtered using the user entered query:
(2) is not pre-filtered, but every user is added to the possible user results: matrix-react-sdk/src/components/views/dialogs/spotlight/SpotlightDialog.tsx Lines 358 to 364 in 7a250f4
The conditional in discussion is thus required to filter the users in (2): matrix-react-sdk/src/components/views/dialogs/spotlight/SpotlightDialog.tsx Lines 414 to 415 in 7a250f4
However, this line will also filter the results that were already filtered by the server. This shouldn't be necessary because I would assume that we can trust that the homeserver returns proper results. ProposalWe would propose some refactorings to remove the double-filtering of the server results: // ...
+ const localUsers = findVisibleRoomMembers(cli, msc3946ProcessDynamicPredecessor).filter(... apply the filtering by trimmedQuery ...);
+ for (const user of [...localUsers, ...users]) {
- for (const user of [...findVisibleRoomMembers(cli, msc3946ProcessDynamicPredecessor), ...users]) {
// Make sure we don't have any user more than once
if (alreadyAddedUserIds.has(user.userId)) continue;
alreadyAddedUserIds.add(user.userId);
userResults.push(toMemberResult(user));
}
// ... With this change, the filtering of the possibleResults can be skipped: - } else if (isMemberResult(entry)) {
- if (!entry.query?.some((q) => q.includes(lcQuery))) return; // bail, does not match query There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further, we suggest to add our use-case to the tests. |
||||||||||||||||||||||
} else if (isPublicRoomResult(entry)) { | ||||||||||||||||||||||
if (!entry.query?.some((q) => q.includes(lcQuery))) return; // bail, does not match query | ||||||||||||||||||||||
} else { | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to remove the if statement completely