Merge pull request #208 from ouchadam/bug/importing-keys-fails-first-time

Room key imports failing the first time
This commit is contained in:
Adam Brown 2022-10-17 23:12:11 +01:00 committed by GitHub
commit 146e30193f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -14,6 +14,8 @@ import com.squareup.sqldelight.TransactionWithoutReturn
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
class OlmPersistence(
private val database: DapkDb,
@ -83,10 +85,12 @@ class OlmPersistence(
}
suspend fun startTransaction(action: suspend TransactionWithoutReturn.() -> Unit) {
val scope = CoroutineScope(dispatchers.io)
database.cryptoQueries.transaction {
scope.launch { action() }
val transaction = suspendCoroutine { continuation ->
database.cryptoQueries.transaction {
continuation.resume(this)
}
}
action(transaction)
}
suspend fun persist(sessionId: SessionId, inboundGroupSession: SerializedObject) {