mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-05 18:23:34 +02:00
Fixing crash when calling localcache on the main thread.
This commit is contained in:
@@ -1358,26 +1358,27 @@ class AccountViewModel(val account: Account, val settings: SettingsState) : View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun cachedDVMContentDiscovery(pubkeyHex: String): Note? {
|
suspend fun cachedDVMContentDiscovery(pubkeyHex: String): Note? =
|
||||||
val fifteenMinsAgo = TimeUtils.fifteenMinutesAgo()
|
withContext(Dispatchers.IO) {
|
||||||
// First check if we have an actual response from the DVM in LocalCache
|
val fifteenMinsAgo = TimeUtils.fifteenMinutesAgo()
|
||||||
val response =
|
// First check if we have an actual response from the DVM in LocalCache
|
||||||
LocalCache.notes.maxOrNullOf(
|
val response =
|
||||||
filter = { key, note ->
|
LocalCache.notes.maxOrNullOf(
|
||||||
val noteEvent = note.event
|
filter = { key, note ->
|
||||||
noteEvent is NIP90ContentDiscoveryResponseEvent &&
|
val noteEvent = note.event
|
||||||
noteEvent.pubKey == pubkeyHex &&
|
noteEvent is NIP90ContentDiscoveryResponseEvent &&
|
||||||
noteEvent.isTaggedUser(account.keyPair.pubKey.toHexKey()) &&
|
noteEvent.pubKey == pubkeyHex &&
|
||||||
noteEvent.createdAt > fifteenMinsAgo
|
noteEvent.isTaggedUser(account.keyPair.pubKey.toHexKey()) &&
|
||||||
},
|
noteEvent.createdAt > fifteenMinsAgo
|
||||||
comparator = CreatedAtComparator,
|
},
|
||||||
)
|
comparator = CreatedAtComparator,
|
||||||
|
)
|
||||||
|
|
||||||
// If we have a response, get the tagged Request Event otherwise null
|
// If we have a response, get the tagged Request Event otherwise null
|
||||||
return response?.event?.tags()?.firstOrNull { it.size > 1 && it[0] == "e" }?.get(1)?.let {
|
return@withContext response?.event?.tags()?.firstOrNull { it.size > 1 && it[0] == "e" }?.get(1)?.let {
|
||||||
LocalCache.getOrCreateNote(it)
|
LocalCache.getOrCreateNote(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun sendZapPaymentRequestFor(
|
fun sendZapPaymentRequestFor(
|
||||||
bolt11: String,
|
bolt11: String,
|
||||||
|
Reference in New Issue
Block a user