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

Feat 1065 filter persistance on asset index #1211

Merged

Conversation

rajeshj11
Copy link
Contributor

No description provided.

Copy link
Contributor

@DonKoko DonKoko left a comment

Choose a reason for hiding this comment

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

Requested some changes mostly related to coding style and conventions we use.
I also did some testing on my localhost and it seems to work. Once those changes are implemented I will also ask a third person to review, in case we are missing something.

app/hooks/use-search-param-utils.ts Outdated Show resolved Hide resolved
app/utils/cookies.server.ts Outdated Show resolved Hide resolved
app/utils/cookies.server.ts Outdated Show resolved Hide resolved
app/routes/_layout+/assets._index.tsx Outdated Show resolved Hide resolved
app/routes/_layout+/assets._index.tsx Outdated Show resolved Hide resolved

function handleValueChange(value: string) {
setSearchParams((prev) => {
/** If the value is "ALL", we just remove the param */
if (value === "ALL") {
destoryCookieValues(["status"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit concerned about this approach, because that requires us to never forget to add this when having functions that clear filters and so on.
A suggestion, what if we create our own abstraction of useSearchParams() that handles this and makes sure that every time a value is removed from the search params, we also remove it from the cookie.

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 could not able to figure out a way to do it due to some scenarios.

  1. Not able to differentiate if the user has cleared the filters in the asset page or if the user is directly going to the asset page after some navigations. (in both cases search parameters are empty.)

Copy link
Contributor

Choose a reason for hiding this comment

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

If the user has search params saved in the cookie, they wont be empty as they come with the server response and useSearchParams checks on the client so I am not sure what you mean here.

app/hooks/use-search-param-utils.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@DonKoko DonKoko left a comment

Choose a reason for hiding this comment

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

Okey we still have quite some stuff to handle here. A few of the filters are currently broken because of this change. For example:

  • manually clearing an item from the dropdown filters doesnt work anymore. I assume its because of what i mentioned before, that if we don't manage the destroyCookieValues(["s"]); somehow globally, it will create sitiations like this where we forgot to add it in 1 place and it causes a bug.

So I did something to help out. I created the abstraction of the setSearchParams that automatically removed search params values that were removed from the cookie.
However this still needs to be further tested and the import of useSearchParams needs to be replaced. Can you please take care of that.
I also placed one inline comment to address.

@rajeshj11
Copy link
Contributor Author

Okey we still have quite some stuff to handle here. A few of the filters are currently broken because of this change. For example:

  • manually clearing an item from the dropdown filters doesnt work anymore. I assume its because of what i mentioned before, that if we don't manage the destroyCookieValues(["s"]); somehow globally, it will create sitiations like this where we forgot to add it in 1 place and it causes a bug.

So I did something to help out. I created the abstraction of the setSearchParams that automatically removed search params values that were removed from the cookie. However this still needs to be further tested and the import of useSearchParams needs to be replaced. Can you please take care of that. I also placed one inline comment to address.

ok will check

…om useSreachParams hook for handling the search params deleting and updation
@DonKoko DonKoko merged commit e03a23c into Shelf-nu:main Jul 30, 2024
4 checks passed
@rajeshj11 rajeshj11 deleted the feat-1065-filter-persistance-on-asset-index branch July 30, 2024 12:18
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.

[Feature request]: Asset index - store searchParams
2 participants