Stabilize feed order with a deterministic signal-score tiebreaker
Equal-score stories reshuffled on every pull-to-refresh because the sort was unstable. Add StorySummary.feedOrder (signalScore desc, then id desc, mirroring the backend's signal_score DESC, id DESC) and use it for the feed, the WebSocket re-sort, and the Saved/Search tabs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -160,3 +160,14 @@ struct ArticleRoute: Hashable {
|
||||
let storyId: String
|
||||
let parentHeadline: String
|
||||
}
|
||||
|
||||
// MARK: - Stable feed ordering
|
||||
|
||||
extension StorySummary {
|
||||
/// Deterministic ranking: signal score descending, then id descending — the
|
||||
/// same order the backend uses (`signal_score DESC, id DESC`). Without the
|
||||
/// id tiebreaker, equal-score stories reshuffle on every (unstable) re-sort.
|
||||
static func feedOrder(_ a: StorySummary, _ b: StorySummary) -> Bool {
|
||||
a.signalScore != b.signalScore ? a.signalScore > b.signalScore : a.id > b.id
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user