shabados / presenter

Desktop app for presenting the Shabad OS Database on projectors, TVs, and live streams
https://shabados.com
MIT License
19 stars 15 forks source link

fix(frontend/controller): improve match highlighting + split up the search component #594

Closed saihaj closed 3 years ago

saihaj commented 4 years ago

Summary of PR

The Results function was very huge and it was getting quite confusing to navigate around. Idea here is to split up the search component so that results becomes its own component and all highlighting is contained there. Search component will pass down all the necessary props.

I tried bringing context down to results (where it makes way much more sense and then we don't have to pass so many things down) but was not possible because it breaks react hooks rules. Later I realized it is also not so great because we are mapping though the list of results we get from backend and that might be too much work each time to get context from the hook.

@Harjot1Singh you probably have some better way because this has reached very high levels of prop drilling.

Fixes

Fixes #567 Fixes #569

TTR

@saihaj - unsure @Harjot1Singh - 2 hours

saihaj commented 4 years ago

Now I have moved all the result related things to Result component. We pass down necessary props to Result component and it will take care of mapping through and highlighting of each search result. It is a first step towards simplifying the search component so that we can start working on #511.

saihaj commented 4 years ago

@Harjot1Singh I need help, I messed up highlighting of a search results when keyboard keys are pressed to select an item.

Harjot1Singh commented 3 years ago

Please check this still works well @bhajneet @saihaj.

I ended up fixing some search highlighting issues, and refactoring the logic into a separate file.

saihaj commented 3 years ago

✅ LGTM This also fixes #567 #569

Harjot1Singh commented 3 years ago

This serves as a very good basis and the preliminary work required by #221, which will serve as one of our biggest performance improvements.