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:
@@ -34,12 +34,12 @@ struct SignalFeedView: View {
|
||||
/// Live stories when online; cached fallback when the feed is empty & offline.
|
||||
private var displayStories: [StorySummary] {
|
||||
if !store.stories.isEmpty {
|
||||
return store.stories.sorted { $0.signalScore > $1.signalScore }
|
||||
return store.stories.sorted(by: StorySummary.feedOrder)
|
||||
}
|
||||
if !ws.connectionState.isLive {
|
||||
return cachedStories
|
||||
.map(StorySummary.init(cached:))
|
||||
.sorted { $0.signalScore > $1.signalScore }
|
||||
.sorted(by: StorySummary.feedOrder)
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user