mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 16:47:01 +05:30
Merge #183
183: Sort saved posts months as well r=msfjarvis a=msfjarvis bors r+ Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
commit
d48d1c44ea
1 changed files with 10 additions and 1 deletions
|
@ -56,7 +56,16 @@ fun SavedPosts(
|
||||||
state = listState,
|
state = listState,
|
||||||
modifier = Modifier.then(modifier),
|
modifier = Modifier.then(modifier),
|
||||||
) {
|
) {
|
||||||
val grouped = posts.groupBy { it.createdAt.asZonedDateTime().month }
|
val grouped =
|
||||||
|
posts.groupBy { it.createdAt.asZonedDateTime().month }.apply {
|
||||||
|
if (sortOrder) {
|
||||||
|
toSortedMap(
|
||||||
|
Comparator { first, second ->
|
||||||
|
return@Comparator if (first > second) -1 else if (first < second) 1 else 0
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
grouped.forEach { (month, posts) ->
|
grouped.forEach { (month, posts) ->
|
||||||
stickyHeader { MonthHeader(month = month) }
|
stickyHeader { MonthHeader(month = month) }
|
||||||
@Suppress("NAME_SHADOWING") val posts = if (sortOrder) posts.reversed() else posts
|
@Suppress("NAME_SHADOWING") val posts = if (sortOrder) posts.reversed() else posts
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue