mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-30 00:40:49 +00:00
Refactors sorting of Notifications
This commit is contained in:
parent
c82c594926
commit
7513036d47
@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.amethyst.ui.dal
|
||||
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.Card
|
||||
import com.vitorpamplona.quartz.events.Event
|
||||
|
||||
val DefaultFeedOrder: Comparator<Note> =
|
||||
@ -37,3 +38,6 @@ val DefaultFeedOrder: Comparator<Note> =
|
||||
}
|
||||
}
|
||||
}.thenBy { it.idHex }
|
||||
|
||||
val DefaultFeedOrderCard: Comparator<Card> =
|
||||
compareByDescending<Card> { it.createdAt() }.thenBy { it.id() }
|
||||
|
@ -31,6 +31,7 @@ import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.service.checkNotInMainThread
|
||||
import com.vitorpamplona.amethyst.ui.dal.AdditiveFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.DefaultFeedOrderCard
|
||||
import com.vitorpamplona.amethyst.ui.dal.FeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.dal.NotificationFeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
||||
@ -111,7 +112,7 @@ class CardFeedContentState(
|
||||
val updatedCards =
|
||||
(oldNotesState.feed.value + newCards)
|
||||
.distinctBy { it.id() }
|
||||
.sortedWith(compareBy({ it.createdAt() }, { it.id() }))
|
||||
.sortedWith(DefaultFeedOrderCard)
|
||||
.reversed()
|
||||
.take(localFilter.limit())
|
||||
.toImmutableList()
|
||||
@ -126,7 +127,7 @@ class CardFeedContentState(
|
||||
|
||||
val cards =
|
||||
convertToCard(notes)
|
||||
.sortedWith(compareBy({ it.createdAt() }, { it.id() }))
|
||||
.sortedWith(DefaultFeedOrderCard)
|
||||
.reversed()
|
||||
.take(localFilter.limit())
|
||||
.toImmutableList()
|
||||
|
Loading…
Reference in New Issue
Block a user