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