Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-1539] Implement searching for the individual words in workspaces #1590

Merged
merged 7 commits into from
Nov 22, 2021
Merged
Prev Previous commit
Next Next commit
Micro-optimization - avoided compiling regex in each iteration
  • Loading branch information
harshilsharma63 committed Oct 26, 2021
commit ed0a339dfdeb2d8621f17821e3d3105e44b5b3f7
3 changes: 2 additions & 1 deletion webapp/src/pages/dashboard/centerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ const DashboardCenterContent = (): JSX.Element => {
initializeUserWorkspaces()
}, [])

const searchPattern = new RegExp(searchFilter.split(' ').join('|'), 'g')
const userWorkspaces = rawWorkspaces.
filter((workspace) => (workspace.boardCount > 0 || showEmptyWorkspaces) && (new RegExp(searchFilter.split(' ').join('|'), 'g').test(workspace.title.toLowerCase()) || workspace.boardCount.toString().includes(searchFilter))).
filter((workspace) => (workspace.boardCount > 0 || showEmptyWorkspaces) && (searchPattern.test(workspace.title.toLowerCase()) || workspace.boardCount.toString().includes(searchFilter))).
sort((a, b) => {
if ((a.boardCount === 0 && b.boardCount === 0) || (a.boardCount !== 0 && b.boardCount !== 0)) {
return a.title.localeCompare(b.title)
Expand Down