Simplifies comparison for Channels via Hex code instead of objects

This commit is contained in:
Vitor Pamplona
2023-04-18 08:41:59 -04:00
parent 78c9974036
commit 38e18cf0a7
2 changed files with 10 additions and 9 deletions

View File

@@ -53,13 +53,14 @@ open class Note(val idHex: String) {
open fun idNote() = id().toNote()
open fun idDisplayNote() = idNote().toShortenHex()
fun channel(): Channel? {
val channelHex =
(event as? ChannelMessageEvent)?.channel()
?: (event as? ChannelMetadataEvent)?.channel()
?: (event as? ChannelCreateEvent)?.id
fun channelHex(): HexKey? {
return (event as? ChannelMessageEvent)?.channel()
?: (event as? ChannelMetadataEvent)?.channel()
?: (event as? ChannelCreateEvent)?.id
}
return channelHex?.let { LocalCache.checkGetOrCreateChannel(it) }
fun channel(): Channel? {
return channelHex()?.let { LocalCache.checkGetOrCreateChannel(it) }
}
open fun address(): ATag? = null

View File

@@ -9,7 +9,7 @@ object GlobalFeedFilter : FeedFilter<Note>() {
lateinit var account: Account
override fun feed(): List<Note> {
val followChannels = account.followingChannels()
val followChannels = account.followingChannels
val followUsers = account.followingKeySet()
val now = System.currentTimeMillis() / 1000
@@ -19,7 +19,7 @@ object GlobalFeedFilter : FeedFilter<Note>() {
it.event is BaseTextNoteEvent && it.replyTo.isNullOrEmpty()
}
.filter {
val channel = it.channel()
val channel = it.channelHex()
// does not show events already in the public chat list
(channel == null || channel !in followChannels) &&
// does not show people the user already follows
@@ -38,7 +38,7 @@ object GlobalFeedFilter : FeedFilter<Note>() {
it.event is LongTextNoteEvent && it.replyTo.isNullOrEmpty()
}
.filter {
val channel = it.channel()
val channel = it.channelHex()
// does not show events already in the public chat list
(channel == null || channel !in followChannels) &&
// does not show people the user already follows