mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-01 00:18:30 +02:00
Removing channel create and change from Notifications Feed
This commit is contained in:
parent
2e17535a60
commit
0f968ca5e5
@ -3,6 +3,9 @@ package com.vitorpamplona.amethyst.service
|
||||
import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
||||
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
||||
import com.vitorpamplona.amethyst.service.model.RepostEvent
|
||||
import nostr.postr.JsonFilter
|
||||
|
||||
object NostrNotificationDataSource: NostrDataSource<Note>("NotificationFeed") {
|
||||
@ -21,7 +24,9 @@ object NostrNotificationDataSource: NostrDataSource<Note>("NotificationFeed") {
|
||||
set.filter { it.event != null }.filter { account.isAcceptable(it) }
|
||||
}
|
||||
|
||||
return filtered.sortedBy { it.event?.createdAt }.reversed()
|
||||
return filtered.filter {
|
||||
it.event !is ChannelCreateEvent && it.event !is ChannelMetadataEvent
|
||||
}.sortedBy { it.event?.createdAt }.reversed()
|
||||
}
|
||||
|
||||
override fun updateChannelFilters() {
|
||||
|
@ -18,11 +18,9 @@ class NoteCard(val note: Note): Card() {
|
||||
|
||||
class LikeSetCard(val note: Note, val likeEvents: List<Note>): Card() {
|
||||
val createdAt = likeEvents.maxOf { it.event?.createdAt ?: 0 }
|
||||
|
||||
override fun createdAt(): Long {
|
||||
return createdAt
|
||||
}
|
||||
|
||||
override fun id() = note.idHex + "L" + createdAt
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@ import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.LocalCacheState
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.service.NostrDataSource
|
||||
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
||||
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
||||
import com.vitorpamplona.amethyst.service.model.ReactionEvent
|
||||
import com.vitorpamplona.amethyst.service.model.RepostEvent
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -56,9 +58,9 @@ class CardFeedViewModel(val dataSource: NostrDataSource<Note>): ViewModel() {
|
||||
private fun convertToCard(notes: List<Note>): List<Card> {
|
||||
val reactionsPerEvent = mutableMapOf<Note, MutableList<Note>>()
|
||||
notes
|
||||
.filter { it.event is ReactionEvent }
|
||||
.filter { it.event is ReactionEvent}
|
||||
.forEach {
|
||||
val reactedPost = it.replyTo?.last()
|
||||
val reactedPost = it.replyTo?.lastOrNull() { it.event !is ChannelMetadataEvent && it.event !is ChannelCreateEvent }
|
||||
if (reactedPost != null)
|
||||
reactionsPerEvent.getOrPut(reactedPost, { mutableListOf() }).add(it)
|
||||
}
|
||||
@ -69,7 +71,7 @@ class CardFeedViewModel(val dataSource: NostrDataSource<Note>): ViewModel() {
|
||||
notes
|
||||
.filter { it.event is RepostEvent }
|
||||
.forEach {
|
||||
val boostedPost = it.replyTo?.last()
|
||||
val boostedPost = it.replyTo?.lastOrNull() { it.event !is ChannelMetadataEvent && it.event !is ChannelCreateEvent }
|
||||
if (boostedPost != null)
|
||||
boostsPerEvent.getOrPut(boostedPost, { mutableListOf() }).add(it)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user