Skip to content

feat: add pagination to knowledge search #11527

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

Merged
merged 23 commits into from
Mar 31, 2025
Merged

feat: add pagination to knowledge search #11527

merged 23 commits into from
Mar 31, 2025

Conversation

ykmsd
Copy link
Contributor

@ykmsd ykmsd commented Mar 21, 2025

Description

This PR is to add pagination when you search knowledge in the input. I also updated InfiniteScroll component and left some comments in the code.

To show the loading state this is throttled:

Screen.Recording.2025-03-21.at.15.00.21.mov

Tests

Manual test and I need your help to test SearchMemberPopover to see if I don't break anything

Risk

Deploy Plan

@ykmsd ykmsd marked this pull request as ready for review March 21, 2025 14:38
@ykmsd ykmsd requested a review from JulesBelveze March 21, 2025 14:38
Copy link
Contributor

@JulesBelveze JulesBelveze left a comment

Choose a reason for hiding this comment

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

Looks 🔥 left a few minor comments

Thinking out loud here, but don't you think we might want to display a message like "Showing 25 results out of ..."?

search: searchQuery,
viewType: "all",
disabled: isSpacesLoading || !searchQuery,
spaceIds: spaces.map((s) => s.sId),
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's maybe extract it with a useMemo?

Copy link
Contributor Author

@ykmsd ykmsd Mar 24, 2025

Choose a reason for hiding this comment

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

I might miss something but will it be worth doing it here? 🤔 (in some places I just threw useMemo for now but if we improve the code structure for this Inputbar we can probably remove some of them, but this would take me to another rabbit hole so I wouldn't touch it for now)

@ykmsd ykmsd force-pushed the yuka/paginated-search branch from f652feb to f00f799 Compare March 24, 2025 11:22
@ykmsd ykmsd requested a review from JulesBelveze March 24, 2025 16:16
@@ -782,3 +783,82 @@ export function useSpacesSearch({
nextPageCursor: data?.nextPageCursor || null,
};
}

export function useSpaceSearchWithInfiniteScroll({
Copy link
Contributor

Choose a reason for hiding this comment

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

Random question: Is there a reason you created a new hook and not extended the existing useSpacesSearch ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm they are actually quite different and I think it's better have separate hooks for them? 🤔

Copy link
Contributor

@spolu spolu left a comment

Choose a reason for hiding this comment

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

(video looks great \o/)

@ykmsd ykmsd requested a review from JulesBelveze March 31, 2025 08:19
Copy link
Contributor

@JulesBelveze JulesBelveze left a comment

Choose a reason for hiding this comment

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

Looks good 🔥


params.append("limit", pageSize.toString());

if (previousPageData && previousPageData?.nextPageCursor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (previousPageData && previousPageData?.nextPageCursor) {
if (previousPageData && previousPageData.nextPageCursor) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will just keep previousPageData?.nextPageCursor :D

@ykmsd ykmsd merged commit bb4f4c8 into main Mar 31, 2025
13 checks passed
@ykmsd ykmsd deleted the yuka/paginated-search branch March 31, 2025 13:24
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.

3 participants