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

Fix search persistence #155

Merged
merged 1 commit into from
Feb 14, 2024
Merged

Fix search persistence #155

merged 1 commit into from
Feb 14, 2024

Conversation

cloverich
Copy link
Owner

Fix search persistence when navigating in and out of notes, if search was not initiated by pagination (i.e. sidebar). Caused by setSearch not updating the URL. Fixing that revealed a loop, and required refactoring to use the route tree to control which components have access to the search store

Notably, in #150 I called this a bug and asked how it broke. It was actually never implemented -- search persistence was only partially implemented. This finishes the implementation, and also improves the design in that components requiring the persistent store all receive it from a shared ancestor (route); removes the need for a couple hacks.

Closes #150

@cloverich cloverich force-pushed the fix-search-persistence branch from e80415c to abc280d Compare February 14, 2024 05:32
const [searchStore, setSearchStore] = useState<null | SearchStore>(null);

// This is more like an effect. This smells. Maybe just roll this all up into
// a hook.
Copy link
Owner Author

Choose a reason for hiding this comment

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

Probably should remove this (copied from container); this component is sufficiently special purpose.

- fix search persistence when navigating in and out of notes, if search was not initiated by pagination (i.e. sidebar). Caused by setSearch not updating the URL. Fixing that revealed a loop, and required refactoring to use the route tree to control which components have access to the search store
- refactor TagSearchStore -> SearchParser; make it stateless and move stateful handling to SearchStore
@cloverich cloverich force-pushed the fix-search-persistence branch from abc280d to 3a511b3 Compare February 14, 2024 05:51
@cloverich cloverich merged commit 1096a15 into master Feb 14, 2024
1 check passed
@cloverich cloverich deleted the fix-search-persistence branch February 14, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Back button doesn't maintain in: state
1 participant