-
Notifications
You must be signed in to change notification settings - Fork 158
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
Feat 1065 filter persistance on asset index #1211
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.
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.
|
||
function handleValueChange(value: string) { | ||
setSearchParams((prev) => { | ||
/** If the value is "ALL", we just remove the param */ | ||
if (value === "ALL") { | ||
destoryCookieValues(["status"]); |
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.
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.
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.
I could not able to figure out a way to do it due to some scenarios.
- 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.)
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.
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.
…com:rajeshj11/shelf.nu into feat-1065-filter-persistance-on-asset-index
…com:rajeshj11/shelf.nu into feat-1065-filter-persistance-on-asset-index
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.
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
…rited in useSearchParams
No description provided.