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

Add custom sorting per community/feed #1492

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

hjiangsu
Copy link
Member

@hjiangsu hjiangsu commented Jul 12, 2024

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?

@micahmo micahmo mentioned this pull request Jul 12, 2024
3 tasks
@micahmo
Copy link
Member

micahmo commented Jul 12, 2024

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 community@instance.tld 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!

/// Generates a username string that can be used to uniquely identify entries in the UserLabels table
static String usernameFromParts(String username, String actorId) {
return '$username@${fetchInstanceNameFromUrl(actorId)}';
}
/// Splits a username generated by [usernameFromParts] back into name and instance
static ({String username, String instance}) partsFromUsername(String username) {
return (username: username.split('@')[0], instance: username.split('@')[1]);
}

This is a super cool feature, by the way!!

@hjiangsu
Copy link
Member Author

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.

@micahmo
Copy link
Member

micahmo commented Jul 13, 2024

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.

@Fmstrat
Copy link
Contributor

Fmstrat commented Jul 13, 2024

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

@micahmo
Copy link
Member

micahmo commented Jul 13, 2024

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!

@Fmstrat
Copy link
Contributor

Fmstrat commented Jul 15, 2024

I think that makes sense, yea.

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.

3 participants