Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

apply roomlist searchFilter to aliases if it begins with a # #1957

Merged
merged 2 commits into from
Jun 15, 2018

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Jun 13, 2018

Fixes element-hq/element-web#5719

applies only if begins with a # otherwise yielded too many false positives when searching for matrix

Signed-off-by: Michael Telatynski [email protected]

Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what's with the h1 on 'Fixes' in the description?

// to prevent loads of false positives with server names, e.g `matrix`
if (filter[0] === '#' && room.getAliases().some((alias) => {
return alias.toLowerCase().startsWith(lcFilter);
})) return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the fact that the conditional is spread over 3 lines disqualifies the from being a line-if, so I'd prefer if we just put the braces in here I think.

return room.name && room.name.toLowerCase().indexOf(filter.toLowerCase()) >= 0
if (room.name && room.name.toLowerCase().includes(lcFilter)) return true;
// only apply search filter to aliases if it looks like an alias (starts with `#`)
// to prevent loads of false positives with server names, e.g `matrix`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't cause false positives from server names though since you use startsWith? It would just never match anything if the filter didn't start with '#' so this is a fast-path optimisation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be .includes like the above then I switched it when I added the startsWith# as we know it's start-anchored

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove the comment if its too redundant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

back to you

@t3chguy
Copy link
Member Author

t3chguy commented Jun 14, 2018

Also, what's with the h1 on 'Fixes' in the description?

so I/others don't miss Dependencies and which issues it Fixes

I've had PRs merged before where it said "Depends on js-sdk#XXXXX" and yet the dependency didn't get merged and thus broke /develop

@t3chguy t3chguy assigned dbkr and unassigned t3chguy Jun 14, 2018
@dbkr dbkr merged commit 349f95d into develop Jun 15, 2018
@t3chguy t3chguy deleted the t3chguy/roomsublist_search_aliases branch May 25, 2020 18:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants