fix: ensure secondary sort by id ascending when sorting by createdAt descending
When events share the same createdAt timestamp, the tiebreaker sort by id must be ascending to produce a stable, deterministic order. Fixed several locations that either had no secondary sort, used descending id sort, or used .reversed() which incorrectly flipped both sort directions. https://claude.ai/code/session_01RvuyPf1x9wLf2DCgsSXLGz
This commit is contained in:
@@ -196,7 +196,7 @@ fun ReadsScreen(
|
||||
remember {
|
||||
EventCollectionState<LongTextNoteEvent>(
|
||||
getId = { it.id },
|
||||
sortComparator = compareByDescending { it.publishedAt() ?: it.createdAt },
|
||||
sortComparator = compareByDescending<LongTextNoteEvent> { it.publishedAt() ?: it.createdAt }.thenBy { it.id },
|
||||
maxSize = 100,
|
||||
scope = scope,
|
||||
)
|
||||
|
||||
+2
-2
@@ -829,7 +829,7 @@ fun UserProfileScreen(
|
||||
}
|
||||
} else {
|
||||
items(
|
||||
articleEvents.sortedByDescending { it.publishedAt() ?: it.createdAt },
|
||||
articleEvents.sortedWith(compareByDescending<LongTextNoteEvent> { it.publishedAt() ?: it.createdAt }.thenBy { it.id }),
|
||||
key = { "art-${it.id}" },
|
||||
) { article ->
|
||||
LongFormCard(
|
||||
@@ -871,7 +871,7 @@ fun UserProfileScreen(
|
||||
}
|
||||
} else {
|
||||
items(
|
||||
highlightEvents.sortedByDescending { it.createdAt },
|
||||
highlightEvents.sortedWith(compareByDescending<HighlightEvent> { it.createdAt }.thenBy { it.id }),
|
||||
key = { "hl-${it.id}" },
|
||||
) { highlight ->
|
||||
PublishedHighlightCard(
|
||||
|
||||
Reference in New Issue
Block a user