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

feat(greader): sort categories alphabetically during sync #700

Merged
merged 1 commit into from
May 31, 2024

Conversation

mbestavros
Copy link
Collaborator

This has been a pet peeve of mine when using the Greader API: categories/folders aren't sorted alphabetically when in the Feeds view. The way the app works today, categories are arranged by whichever category has the feed with the lowest lexicographical order, which is very unintuitive.

As an example, let's say I have the following categories and feeds:

"Apples": {
    "feeds": ["Fruits of the Day"]
},
"Bananas": {
    "feeds": ["A banana a day keeps the doctor away"]
},

Under the current code, these categories get ordered as:

Bananas
Apples

because A banana a day keeps the doctor away is lexicographically before Fruits of the Day.

While it's true that we should probably implement some way to allow the user to manually reorder feeds, this is a quick fix that requires little effort. Plus, even if we did have manual category sorting, it's still nice to present a sensible lexicographic default.

Tagging @Ashinch and @JunkFood02 for review.

@mbestavros mbestavros requested a review from Ashinch May 21, 2024 21:04
@mbestavros
Copy link
Collaborator Author

Related: #535

@@ -228,7 +228,7 @@ class GoogleReaderRssService @Inject constructor(

// 2. Fetch folder and subscription list
googleReaderAPI.getSubscriptionList()
.subscriptions.groupBy { it.categories?.first() }
.subscriptions.sortedBy { it.categories?.sortedBy { it.label }?.first()?.label }.groupBy { it.categories?.first() }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems a bit complicated for me. Though I don't use Google Reader, I guess we only need the first (and the only) element in categories here. And we can sort the map after we group the list by the category.

@@ -228,7 +228,7 @@ class GoogleReaderRssService @Inject constructor(

// 2. Fetch folder and subscription list
googleReaderAPI.getSubscriptionList()
.subscriptions.groupBy { it.categories?.first() }
.subscriptions.sortedBy { it.categories?.sortedBy { it.label }?.first()?.label }.groupBy { it.categories?.first() }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.subscriptions.sortedBy { it.categories?.sortedBy { it.label }?.first()?.label }.groupBy { it.categories?.first() }
.subscriptions.groupBy { it.categories?.first() }
.toSortedMap { c1, c2 -> c1?.label.toString().compareTo(c2?.label.toString()) }

Copy link
Collaborator Author

@mbestavros mbestavros May 31, 2024

Choose a reason for hiding this comment

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

@JunkFood02 Yeah, I like this better. Tested it and it works well. Added! Thanks for the suggestion!

Signed-off-by: Mark Bestavros <markbest@bu.edu>
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