Fixes more places where Android's coroutine cancellations might affect a mutex.
This commit is contained in:
@@ -22,8 +22,10 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.NonCancellable
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import nostr.postr.Contact
|
import nostr.postr.Contact
|
||||||
import nostr.postr.Persona
|
import nostr.postr.Persona
|
||||||
import nostr.postr.Utils
|
import nostr.postr.Utils
|
||||||
@@ -424,11 +426,16 @@ class Account(
|
|||||||
handlerWaiting.set(true)
|
handlerWaiting.set(true)
|
||||||
val scope = CoroutineScope(Job() + Dispatchers.Default)
|
val scope = CoroutineScope(Job() + Dispatchers.Default)
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
try {
|
||||||
delay(100)
|
delay(100)
|
||||||
live.refresh()
|
live.refresh()
|
||||||
|
} finally {
|
||||||
|
withContext(NonCancellable) {
|
||||||
handlerWaiting.set(false)
|
handlerWaiting.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun isHidden(user: User) = user in hiddenUsers()
|
fun isHidden(user: User) = user in hiddenUsers()
|
||||||
|
|
||||||
|
|||||||
@@ -298,11 +298,16 @@ class UserLiveData(val user: User): LiveData<UserState>(UserState(user)) {
|
|||||||
handlerWaiting.set(true)
|
handlerWaiting.set(true)
|
||||||
val scope = CoroutineScope(Job() + Dispatchers.Main)
|
val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
try {
|
||||||
delay(100)
|
delay(100)
|
||||||
refresh()
|
refresh()
|
||||||
|
} finally {
|
||||||
|
withContext(NonCancellable) {
|
||||||
handlerWaiting.set(false)
|
handlerWaiting.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun refresh() {
|
private fun refresh() {
|
||||||
postValue(UserState(user))
|
postValue(UserState(user))
|
||||||
|
|||||||
Reference in New Issue
Block a user