-
-
Notifications
You must be signed in to change notification settings - Fork 829
fix(search): add new relevance sort order #1392
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, that was fast @xuatz!
Overall, the PR looks good to me, however there's a couple of changes I think we need to do:
- Relevance doesn't make much sense when we're not in a the "search" page, can we hide the relevance option when we're not in the search page?
- Similarly, I think we should change the
getBookmarks
endpoint to not acceptrelevance
as one of its sort orders.
Hi, Can I ask why we can't choose the sort order when querying from the API? I can imagine uses for it. |
@thiswillbeyourgithub it's an oversight, if you send a PR, I'll happily accept it :) |
Thanks for the quick reply. Unfortunately I'm useless at typescript (although Karakeep is a good reason for me to focus more on it!) so I just want to explicitely state that I won't make a PR (i.e. don't wait for me). |
If it's okay to slightly bloat the PR scope I can include it here! |
@thiswillbeyourgithub actually, i change my mind. it involves updating the openapi docs at which I'm not opposed to, but i'm not familiar with. i'll do it in a separate PR. |
for point number 2, I initially went for the approach to make 2 zSortOrders const zSearchBookmarksSortOrder = z.enum(["asc", "desc", "relevance"]);
const zGetBookmarksSortOrder = z.enum(["asc", "desc"]);
export type ZSortOrder = z.infer<typeof zSearchBookmarksSortOrder>; But because they both share the same I guess we can make 2 stores, one specifically for Instead I've added a cleanup useEffect in // also see related on page enter sortOrder.relevance init
// in apps/web/app/dashboard/search/page.tsx
useEffect(() => {
if (!isDashboardSearchPage && currentSort === "relevance") {
// reset to default sort order
setSortOrder("desc");
}
}, [isDashboardSearchPage, currentSort]); Hard to say which approach you prefer, or if you have a 3rd idea, let me know 👍 |
582dcc6
to
819217f
Compare
4431fef
to
819217f
Compare
Thanks a lot @xuatz! |
* fix(search): add new relevance sort order * address pr comments * some minor fixes --------- Co-authored-by: Mohamed Bassem <me@mbassem.com>
Summary
relevance
relevance
asc
anddesc
sort logicfixes #1335
Notes
I'm wasn't super sure how karakeep handles the translation, so let me know if there are follow up tasks, and anything else that I should tweak for this PR, thanks!