beyondhb1079 / s4us

S4US (Scholarships For Undocumented Students) aims to provide scholarships information for undocumented students
https://www.dreamscholars.org
2 stars 1 forks source link

Pagination: URL parameter support #324

Closed josueetcom closed 2 years ago

josueetcom commented 3 years ago

URL parameters usually encode information about pages to make pages easier to share. E.g. compare the q and start parameter values with what's presented in the query and the page number here: https://www.google.com/search?q=url+parameters+filter&start=10

We want something like the start value here. Except that, since pagination with Firestore is hard, instead of pages let's look at the selected scholarship ID in the URL parameter if it exists and load scholarships until it shows up. So maybe something like this:

  1. If there's no scholarship ID in the URL, just load the first 10 scholarships.
  2. Otherwise:
    1. Load the first 10 scholarships.
    2. If the scholarship ID is not in the first 10 scholarships, fetch the referenced scholarship individually and check if it even matches the query (perhaps it was deleted or updated and no longer shows up in the query)
    3. If it does match the query, keep loading 10 scholarships at a time until the scholarship shows up.
    4. Otherwise:
      1. If the scholarship exists, display the scholarship before the other results add a message explaining it doesn't fit the criteria for showing up anymore (either due to the deadline passing or filters not matching etc.)
      2. Or show an error message saying it's not found.
josueetcom commented 3 years ago

Suggestion: history.push a new location with search set to a new query string with the parameter added/replaced. You might need a library like query-string.

josueetcom commented 2 years ago

Closing this as I think we can do without this.