marsara9 / lemmy-search

An enhanced search engine just for Lemmy/Fediverse
https://www.search-lemmy.com
GNU Affero General Public License v3.0
81 stars 4 forks source link

If preferred_instance= is missing, default to preferred instance stored in cookie #17

Closed rcmaehl closed 1 year ago

rcmaehl commented 1 year ago

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

I'd like to be able to link users to a specific query and have it use their preferred instance for the search. E.g.

https://search-lemmy.com/results?query=lemmyverse

Describe the solution you'd like

Per our discord conversation, the preferred instance is stored as a cookie.

If the cookie is missing and the above URL is used, potentially drop them on the homepage with the query already filled(?)

Describe alternatives you've considered

Prompting the user every time - Seems excessive Defaulting to Lemmy.world - This is bad practice, even if everyone else is currently doing it

Additional context

marsara9 commented 1 year ago

Currently the preferred-instance is stored as a cookie. This query parameter can be completely drop and the value can just be read from the cookie directly.

References: https://github.com/marsara9/lemmy-search/blob/master/ui/results/results.js#L214 https://github.com/marsara9/lemmy-search/blob/master/ui/results/results.js#L10

So on line 10 above, instead of just copying the query that was passed to /results directly, the query string will just need to be re-constructed and the preferred instance determined by what's stored in the cookie instead of what was passed in the query string.