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

Fix home page not using site-level listing type #1612 #1778

Conversation

jcgurango
Copy link
Contributor

This is a fix for #1612

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

Looks good, but @SleeplessOne1917 should take a look.

if (isBrowser()) {
const searchParams = new URLSearchParams(window.location.search);

return Array.from(Object.entries(processors)).reduce(
(acc, [key, process]) => ({
...acc,
[key]: process(searchParams.get(key)),
[key]: process(searchParams.get(key), site),
Copy link
Member

Choose a reason for hiding this comment

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

Why would a GetSiteResponse necessarily have properties that should be query params?

Copy link
Contributor Author

@jcgurango jcgurango Jul 3, 2023

Choose a reason for hiding this comment

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

It's for implementing the fallback for listing type to the site-level setting set in the site admin. If later sort type becomes settable in the admin it'd go for that too. Would it make more sense to do something like return null in these callbacks and do the fallback on the home component?

Copy link
Member

Choose a reason for hiding this comment

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

Would it make more sense to do something like return null in these callbacks and do the fallback on the home component?

Yes. You don't want any of these props in the query params since no page uses them:

export interface GetSiteResponse {
  site_view: SiteView;
  admins: Array<PersonView>;
  version: string;
  my_user?: MyUserInfo;
  all_languages: Array<Language>;
  discussion_languages: Array<LanguageId>;
  taglines: Array<Tagline>;
  custom_emojis: Array<CustomEmojiView>;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I've updated that.

@dessalines dessalines merged commit 26ff0f7 into LemmyNet:main Jul 4, 2023
1 check passed
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.

None yet

3 participants