mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 21:47:07 +02:00
Use the default comparator instead of creating a new object every time
This commit is contained in:
@@ -46,12 +46,12 @@ class ChatroomListNewFeedFilter(val account: Account) : AdditiveFeedFilter<Note>
|
|||||||
|
|
||||||
val privateMessages =
|
val privateMessages =
|
||||||
newChatrooms.mapNotNull { it ->
|
newChatrooms.mapNotNull { it ->
|
||||||
it.value.roomMessages.sortedWith(compareBy({ it.createdAt() }, { it.idHex })).lastOrNull {
|
it.value.roomMessages.sortedWith(DefaultFeedOrder).firstOrNull {
|
||||||
it.event != null
|
it.event != null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return privateMessages.sortedWith(compareBy({ it.createdAt() }, { it.idHex })).reversed()
|
return privateMessages.sortedWith(DefaultFeedOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateListWith(
|
override fun updateListWith(
|
||||||
|
@@ -21,5 +21,23 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.dal
|
package com.vitorpamplona.amethyst.ui.dal
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
|
import com.vitorpamplona.quartz.events.Event
|
||||||
|
|
||||||
val DefaultFeedOrder = compareBy<Note>({ it.createdAt() }, { it.idHex }).reversed()
|
val DefaultFeedOrder: Comparator<Note> =
|
||||||
|
compareBy<Note>(
|
||||||
|
{
|
||||||
|
val noteEvent = it.event
|
||||||
|
if (noteEvent == null) {
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
if (noteEvent is Event) {
|
||||||
|
noteEvent.createdAt
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
it.idHex
|
||||||
|
},
|
||||||
|
).reversed()
|
||||||
|
Reference in New Issue
Block a user