Shelf-nu / shelf.nu

shelf is open source Asset Management Infrastructure for absolutely everyone.
https://shelf.nu
GNU Affero General Public License v3.0
1.67k stars 145 forks source link

[Feature request]: Asset index - store searchParams #1065

Open DonKoko opened 1 month ago

DonKoko commented 1 month ago

Contact Details

No response

Is your feature request related to a problem? Please describe?

When I have some filters active on the asset asset and then I navigate to a different page, I want those filters to persist when I come back to the asset index.

Describe the solution you'd like

Store the searchParams in a localStorage, the question is how do we make this smooth. The reason I ask is because localStorage is only accessible on the client, so it will be a very ugly flickr if we trigger the loader and once we get localStorage params it will reload basically.

Describe alternatives you've considered

No response

Additional context

No response

DonKoko commented 2 days ago

hey @rphlmr. I know you used that a lot so I wanted to hear your opinion. Could we maybe use the clientLoader to prevent this issue from happening when we are storing this data on the client?

rphlmr commented 1 day ago

Hey 👋 If you want to reuse them in the loader when you come back to the page it will not work. We can't modify the request, even before await serverLoader().

What about a cookie (not necessary a session cookie, a basic one)? You scope it to the page where it is needed and in the loader you check for searchParams or cookie.

DonKoko commented 1 day ago

@rphlmr yeah I think we might have to go the cookie way. I like the idea of scoping it based on the path of the assets index so we don't send it with each request but only for that url.

@rajeshj11 is this an issue you might want to work on?

rajeshj11 commented 1 day ago

@rphlmr yeah I think we might have to go the cookie way. I like the idea of scoping it based on the path of the assets index so we don't send it with each request but only for that url.

@rajeshj11 is this an issue you might want to work on?

yeah, i would like to give it a try.

rajeshj11 commented 1 day ago

@DonKoko please assign it to me. I will also check other approaches and will let you know about them before start the development

DonKoko commented 1 day ago

Thanks @rajeshj11 . I think the cookie approach is still the best as we can handle it on the server this way. Let me know and lets get started on this.