Skip to content

Commit

Permalink
Fix challenge sort order to match the server-side ordering. (#1330)
Browse files Browse the repository at this point in the history
The app was sorting the challenges by decreasing member count, but the server
returns challenges in order of creation date (with official challenges overriding
the ordering). This should fix the challenges jumping around.

Fixes #1307.
  • Loading branch information
JBYoshi authored Jul 16, 2024
1 parent ad80c51 commit 605c448
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public class SocialLocalRepository: BaseLocalRepository {
query = RealmChallenge.findAll()
}
// swiftlint:disable:next force_unwrapping
return query!.sorted(key: "memberCount", ascending: false).reactive().map({ (value, changeset) -> ReactiveResults<[ChallengeProtocol]> in
return query!.sorted(by: [SortDescriptor(keyPath: "official", ascending: false), SortDescriptor(keyPath: "createdAt", ascending: false)]).reactive().map({ (value, changeset) -> ReactiveResults<[ChallengeProtocol]> in
return (value.map({ (challenge) -> ChallengeProtocol in return challenge }), changeset)
})
}
Expand Down

0 comments on commit 605c448

Please sign in to comment.