Skip to content

Commit

Permalink
fix bluesky ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlaster committed Sep 12, 2024
1 parent 7c2a37d commit 16b9158
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ object Bluesky {
pagingKey: String,
database: CacheDatabase,
data: List<FeedViewPost>,
sortIdProvider: (FeedViewPost) -> Long = { it.post.indexedAt.toEpochMilliseconds() },
sortIdProvider: (FeedViewPost) -> Long = {
val reason = it.reason
if (reason is FeedViewPostReasonUnion.ReasonRepost) {
reason.value.indexedAt.toEpochMilliseconds()
} else {
it.post.indexedAt.toEpochMilliseconds()
}
},
) {
val timeline = data.map { it.toDbPagingTimeline(accountKey, pagingKey, sortIdProvider) }
val status = data.map { it.toDbStatus(accountKey) }
Expand Down Expand Up @@ -173,7 +180,14 @@ private fun ListNotificationsNotification.toDbStatus(accountKey: MicroBlogKey):
fun FeedViewPost.toDbPagingTimeline(
accountKey: MicroBlogKey,
pagingKey: String,
sortIdProvider: (FeedViewPost) -> Long = { it.post.indexedAt.toEpochMilliseconds() },
sortIdProvider: (FeedViewPost) -> Long = {
val data = it.reason
if (data is FeedViewPostReasonUnion.ReasonRepost) {
data.value.indexedAt.toEpochMilliseconds()
} else {
it.post.indexedAt.toEpochMilliseconds()
}
},
): DbPagingTimeline {
val sortId = sortIdProvider(this)
val status = this.toDbStatus(accountKey)
Expand Down

0 comments on commit 16b9158

Please sign in to comment.