Fixing crash when calling localcache on the main thread.

This commit is contained in:
Vitor Pamplona
2024-05-30 11:21:39 -04:00
parent 632c78792a
commit 36b0c8acb5
@@ -1358,7 +1358,8 @@ class AccountViewModel(val account: Account, val settings: SettingsState) : View
} }
} }
suspend fun cachedDVMContentDiscovery(pubkeyHex: String): Note? { suspend fun cachedDVMContentDiscovery(pubkeyHex: String): Note? =
withContext(Dispatchers.IO) {
val fifteenMinsAgo = TimeUtils.fifteenMinutesAgo() val fifteenMinsAgo = TimeUtils.fifteenMinutesAgo()
// First check if we have an actual response from the DVM in LocalCache // First check if we have an actual response from the DVM in LocalCache
val response = val response =
@@ -1374,7 +1375,7 @@ class AccountViewModel(val account: Account, val settings: SettingsState) : View
) )
// 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)
} }
} }