Change Topic List home router - from Latest to Following

Hi you all!

I’m trying to change default home topic list router, but I haven’t found anyway yet! I hope you guys can help me.

I’m trying from “Latest” to “Following” (would be topics created by user i’m following).

Ways I have tried:

  • The most efficient way would be to add a top menu “following”, but didn’t workout.
  • Other way was by Installing Custom top navigation links. It allowed me to add control nav links but route path “/” (root) is yet coming the “Latest”
  • Other was was by manipulating “discourse/app/routes/app-route-map.js” where is defined the “filters”. But didn’t workout too.
    • this.route("discovery", { path: "/", resetNamespace: true }, function () {

My goal:

  • Change the Topic List that comes from “http://localhost:3000/” from “Latest” to “Following”, it’s possible thankful to Follow Plugin 👨. Because this route already exists, so If I get “/following” it works, but I wanted this route to perform over “/” path.

Is it possible !?

Hope you guys help me!
Best Regards,
Felipe

My recent PR might give you some help.

Here I added Bookmarks to the possible default view:

The hardest part was adding the test cases! :slight_smile:

I would consider this as a PR to the plugin. The tricky part is that it currently only appears if there is something to show … so you’d need to consider that …

3 Likes

Hi Robert! I have changed both files from PR you mentioned.

  • discourse/app/models/user_option.rb
    • when 7 then “following”
  • discourse/app/controllers/preferences/interface.js
    • Changing USER_HOMES constant adding “following”
      Screen Shot 2020-11-11 at 18.08.20

Didn’t workout, I thought with these changes would be possible to choose “Top menu” site settings. So If “latest” is required I would put “following” - “latest” in sequence, this way home would be redirected to “following”.

I found a way during development from

import { setDefaultHomepage } from 'discourse/lib/utilities';

So, in my component, in the beginning I have put

setDefaultHomepage("following");

Because in Rails Console, I have found a variable SiteSetting.homepage which was “latest”.
And worked :smiley:!

Do you see any problems ?

I’m afraid of loading latest from backend and initializer to be loaded in client-side.

Best Regards,
Felipe

1 Like

No you won’t be able to change the Ruby file directly. It was just a clue. After all you will not be submitting a PR to core like I was doing in that case. You will have to find some way of amending that from the plugin initialiser in plugin.rb I suspect … this will be a change to the plugin not core.

1 Like

Yoo!

In plugin.rb, as you said I was capable by putting “following” as the only option:

UserOption.class_eval do
	def homepage 
		"following"
	end 
end
1 Like

Haha, well that’s one way of doing it, but really you should append it as an option, and always give the user the option to change it … at least if you want this to be merged into the plugin :wink:

But yeah, good stuff, keep evolving it.

btw, also take a look at:

3 Likes