mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-08 11:58:03 +02:00
Fixes crash when MuteList has e
tags that are not valid hexes
This commit is contained in:
parent
c0a9ce8e21
commit
5109b65e37
@ -20,9 +20,11 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.dal
|
||||
|
||||
import android.util.Log
|
||||
import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import kotlinx.coroutines.CancellationException
|
||||
|
||||
class HiddenAccountsFeedFilter(val account: Account) : FeedFilter<User>() {
|
||||
override fun feedKey(): String {
|
||||
@ -34,7 +36,15 @@ class HiddenAccountsFeedFilter(val account: Account) : FeedFilter<User>() {
|
||||
}
|
||||
|
||||
override fun feed(): List<User> {
|
||||
return account.flowHiddenUsers.value.hiddenUsers.reversed().map { LocalCache.getOrCreateUser(it) }
|
||||
return account.flowHiddenUsers.value.hiddenUsers.reversed().mapNotNull {
|
||||
try {
|
||||
LocalCache.getOrCreateUser(it)
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
Log.e("HiddenAccountsFeedFilter", "Failed to parse key $it")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.vitorpamplona.quartz.encoders.HexKey
|
||||
import com.vitorpamplona.quartz.signers.NostrSigner
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
import kotlinx.collections.immutable.toImmutableSet
|
||||
import java.util.HashSet
|
||||
|
||||
@Immutable
|
||||
abstract class GeneralListEvent(
|
||||
@ -61,12 +62,13 @@ abstract class GeneralListEvent(
|
||||
key: String,
|
||||
privateTags: Array<Array<String>>?,
|
||||
): ImmutableSet<String> {
|
||||
val privateUserList =
|
||||
privateTags?.let { it.filter { it.size > 1 && it[0] == key }.map { it[1] }.toSet() }
|
||||
?: emptySet()
|
||||
val publicUserList = tags.filter { it.size > 1 && it[0] == key }.map { it[1] }.toSet()
|
||||
val result = HashSet<String>(tags.size + (privateTags?.size ?: 0))
|
||||
|
||||
return (privateUserList + publicUserList).toImmutableSet()
|
||||
privateTags?.let { it.filter { it.size > 1 && it[0] == key }.mapTo(result) { it[1] } }
|
||||
|
||||
tags.filter { it.size > 1 && it[0] == key }.mapTo(result) { it[1] }
|
||||
|
||||
return result.toImmutableSet()
|
||||
}
|
||||
|
||||
fun isTagged(
|
||||
|
Loading…
x
Reference in New Issue
Block a user