IEEE-VIT / templa-rs

One-Stop Solution for all boilerplate needs!
MIT License
28 stars 22 forks source link

refractor: moved app state into App struct and optimized search #29

Closed Daemondeal closed 3 years ago

Daemondeal commented 3 years ago

I created a new App struct to store the app's current state in. This makes the code a little bit cleaner, as it separates the app's state from the drawing logic. With this change, the search feature has been optimized: now it caches the results in the app struct, and it performs new searches if and only if it needs to (For now, it searches only once, but this will become more relevant once we add a search bar). Also, by doing this i fixed the fact that on empty searches nothing was shown (now it shows every possible template), and the broken wrap around when a user tries to go up at index zero in the list, or down at the last index (previously, the cursor would disappear, and the program would crash if you pressed Enter).

All these changes will help to create further menus more easily, as now you can potentially track what menu you're in directly inside the app status.

mintbomb27 commented 3 years ago

Thanks a lot for your contribution! We'll be reviewing your code soon :)

Daemondeal commented 3 years ago

Great! I've got the search bar ready for when this gets approved.

Mannan-Goyal commented 3 years ago

LGTM! Merging