FEATURE: Allow the user to select a custom home page (PR #5268)

GitHub

Thanks for contributing this pull request! Could you please sign our CLA so we can review it? http://www.discourse.org/cla

I have signed the CLA.

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

Rebased.

The title of this pull request changed from “Allow the user to select a custom home page” to "FEATURE: Allow the user to select a custom home page

Why not use a hash instead of a giant switch/case?

const USER_HOMES = { 1: "latest", 2: "categories", ..., 5: "top" };

homeChanged() {
  const siteHome = Discourse.SiteSettings.top_menu.split("|")[0].split(",")[0];
  const userHome = USER_HOMES[this.get('model.user_option.user_home')];
  setDefaultHomepage(userHome || siteHome);
}

Good call.

wait, what if homepage is set to nil in user option, it should be homepage then not anonymous_hompage

test with “unread” as the first in the list

this should not default to 0 it should default to nil, unset by user

getting close :heart:

homepage is not the setting. user_home is the setting.

homepage is a method with this definition.

Done.

I see, makes sense

OK only last bit is that I am unsure about the name

User.first.user_option.user_home

Its already a user option so why does it need the prefix?

I think homepage or homepage_id work better and are more consistent

I would go with homepage_id and then you can keep your hompage helper that returns text.

user_home :arrow_right: homepage_id

This should fix all of the complaints.

Thanks heaps for all your work here @notriddle !!! Merging this in! :shaved_ice: