Fixes crash when MuteList has e tags that are not valid hexes
This commit is contained in:
@@ -20,9 +20,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.dal
|
package com.vitorpamplona.amethyst.ui.dal
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
|
import kotlinx.coroutines.CancellationException
|
||||||
|
|
||||||
class HiddenAccountsFeedFilter(val account: Account) : FeedFilter<User>() {
|
class HiddenAccountsFeedFilter(val account: Account) : FeedFilter<User>() {
|
||||||
override fun feedKey(): String {
|
override fun feedKey(): String {
|
||||||
@@ -34,7 +36,15 @@ class HiddenAccountsFeedFilter(val account: Account) : FeedFilter<User>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun feed(): List<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 com.vitorpamplona.quartz.signers.NostrSigner
|
||||||
import kotlinx.collections.immutable.ImmutableSet
|
import kotlinx.collections.immutable.ImmutableSet
|
||||||
import kotlinx.collections.immutable.toImmutableSet
|
import kotlinx.collections.immutable.toImmutableSet
|
||||||
|
import java.util.HashSet
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
abstract class GeneralListEvent(
|
abstract class GeneralListEvent(
|
||||||
@@ -61,12 +62,13 @@ abstract class GeneralListEvent(
|
|||||||
key: String,
|
key: String,
|
||||||
privateTags: Array<Array<String>>?,
|
privateTags: Array<Array<String>>?,
|
||||||
): ImmutableSet<String> {
|
): ImmutableSet<String> {
|
||||||
val privateUserList =
|
val result = HashSet<String>(tags.size + (privateTags?.size ?: 0))
|
||||||
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()
|
|
||||||
|
|
||||||
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(
|
fun isTagged(
|
||||||
|
|||||||
Reference in New Issue
Block a user