Add custom sorting per community/feed
Pull Request Description
This is a draft PR which implements the ability to save the sort type per-community/feed. A new database table was created to store the custom sorting, and a new option was added the Settings -> General -> Remember Feed Sort Type.
The precedence of sorting is as follows:
- If the user is not logged in, it will default to Thunder's sorting preference
- If the user is logged in, but Remember Feed Sort Type is disabled, then it will default to the user account's sorting preference
- If the user is logged in and Remember Feed Sort Type is enabled, then the default sorting will be the account's sorting preference unless it was previously changed. (e.g., when a user first visits Thunder's Lemmy community, it will be sorted based on their account's default sort type. If the user changes the sort type while in the Thunder's Lemmy community, any future visits to the community will use their last selected sort)
To do this, I had to move the logic of determining the sort type to the FeedBloc. FeedPage no longer has a parameter for the sort type, and the only way to change the sort type for a feed is to call the FeedChangeSortTypeEvent event.
This is still in draft because I want to do some additional testing for the database migrations to ensure it works as expected.
Issue Being Fixed
Issue Number: #1425, #1145, #703
Screenshots / Recordings
Checklist
- [ ] If a new package was added, did you ensure it uses an appropriate license and is actively maintained?
- [ ] Did you use localized strings (and added appropriate descriptions) where applicable?
- [ ] Did you add
semanticLabels where applicable for accessibility?
Hey I know this is still a draft, but I wanted to leave a quick comment! You may want to consider storing the sorting info in the format [email protected] as the identifier, rather than using the community ID. That will allow us to remember the sort type for a given community regardless of what instance the user is on. I used a similar approach for user labels so they can work across instances. You can use these helper methods as inspiration, if you think it's a good approach. Up to you, of course!
https://github.com/thunder-app/thunder/blob/108605b8bd3473d1a078739454c1d513b17516a9/lib/account/models/user_label.dart#L106-L114
This is a super cool feature, by the way!!
That will allow us to remember the sort type for a given community regardless of what instance the user is on.
Thanks for the suggestion! I originally made this feature to be account specific (e.g., each account can have it's own set of sort type for the same community/feed).
With your suggestion, were you suggesting that the sort type should be consistent across different accounts? (e.g., multiple accounts accessing the same community would get the same sort type) I'm not too sure which method is the best way to go about this, but if you have any thoughts or opinions, please let me know!
I'll pull in @K4LCIFER, @kellyaster, and @Fmstrat as well since they're the authors of the original feature requests.
were you suggesting that the sort type should be consistent across different accounts? (e.g., multiple accounts accessing the same community would get the same sort type)
Yes, that's what I had in mind! But if you think it should be per community per account, that would work too!
Another thing we can do is see how other apps handle this feature.
In my opinion of 1, multiple accounts could be used 2 ways:
- Tracking different subscriptions
- Shit posting
In either situation, it's possible a user would want to view new posts in one subscription feed and top in another, so having a unique primary feed sort per qccount would be beneficial.
That being said, individual community feeds unique to each account probably won't matter much.
Assuming the PR allows for 'make my default community and (other) account views sort by "new"', and 'tailor my all and subscription feeds to sort by "top X"', it will cover most use cases regardless.
Edit: To be specific, this is the most varience I think the majority would have:
- Account 1
- Sort All Posts by Top Day
- Sort Subscriptions by Top Day
- Sort all communities by default by New
- Sort all account views by default by New
- Account 2
- Sort All Posts by New
- Sort Subscriptions by New
- Sort all communities by default by New
- Sort all account views by default by New
Thanks for the input @Fmstrat! I totally agree that being able to sort the main feed types (All, Local, Subscriptions) per account makes total sense, especially since different accounts are most likely on different instances, with which you would want to interact differently.
In your example, it would be ok to have the same sort type for a community across accounts, right? I think that also makes sense to me. For example, the Thunder community doesn't have a ton of activity, so I always like to view it chronologically. I would like to make that change once and have it apply to all of my accounts.
P.S. Boost remembers community sorts globally, but not feed sorts per account, so we would have an advantage there. (It also has a setting for whether or not to remember per-community sorts, and a screen to manage any saved ones.) Sync amazingly doesn't seem to remember sorting per community at all!
Again, this is also just my opinion as well and I'm hoping others will chime in!
I think that makes sense, yea.