mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Format code & add comments
This commit is contained in:
parent
a959a15636
commit
277619d833
@ -213,6 +213,7 @@ internal fun ThreadSummaryEntity.Companion.createOrUpdate(
|
||||
}
|
||||
}
|
||||
|
||||
// note: runBlocking should be used here while we are in realm single thread executor, to avoid thread switching
|
||||
private fun decryptIfNeeded(cryptoService: CryptoService?, eventEntity: EventEntity, roomId: String) = runBlocking {
|
||||
cryptoService ?: return@runBlocking
|
||||
val event = eventEntity.asDomain()
|
||||
|
@ -101,9 +101,7 @@ internal class TimelineEventDecryptor @Inject constructor(
|
||||
executor?.execute {
|
||||
Realm.getInstance(realmConfiguration).use { realm ->
|
||||
try {
|
||||
runBlocking {
|
||||
processDecryptRequest(request, realm)
|
||||
}
|
||||
processDecryptRequest(request, realm)
|
||||
} catch (e: InterruptedException) {
|
||||
Timber.i("Decryption got interrupted")
|
||||
}
|
||||
@ -113,16 +111,18 @@ internal class TimelineEventDecryptor @Inject constructor(
|
||||
|
||||
private fun threadAwareNonEncryptedEvents(request: DecryptionRequest, realm: Realm) {
|
||||
val event = request.event
|
||||
realm.executeTransaction {
|
||||
val eventId = event.eventId ?: return@executeTransaction
|
||||
val eventEntity = EventEntity
|
||||
.where(it, eventId = eventId)
|
||||
.findFirst()
|
||||
val decryptedEvent = eventEntity?.asDomain()
|
||||
threadsAwarenessHandler.makeEventThreadAware(realm, event.roomId, decryptedEvent, eventEntity)
|
||||
realm.executeTransaction {
|
||||
val eventId = event.eventId ?: return@executeTransaction
|
||||
val eventEntity = EventEntity
|
||||
.where(it, eventId = eventId)
|
||||
.findFirst()
|
||||
val decryptedEvent = eventEntity?.asDomain()
|
||||
threadsAwarenessHandler.makeEventThreadAware(realm, event.roomId, decryptedEvent, eventEntity)
|
||||
}
|
||||
}
|
||||
private suspend fun processDecryptRequest(request: DecryptionRequest, realm: Realm) {
|
||||
|
||||
// note: runBlocking should be used here while we are in realm single thread executor, to avoid thread switching
|
||||
private fun processDecryptRequest(request: DecryptionRequest, realm: Realm) = runBlocking {
|
||||
val event = request.event
|
||||
val timelineId = request.timelineId
|
||||
|
||||
@ -130,7 +130,7 @@ internal class TimelineEventDecryptor @Inject constructor(
|
||||
// Here we have requested a decryption to an event that is not encrypted
|
||||
// We will simply make this event thread aware
|
||||
threadAwareNonEncryptedEvents(request, realm)
|
||||
return
|
||||
return@runBlocking
|
||||
}
|
||||
try {
|
||||
val result = cryptoService.decryptEvent(request.event, timelineId)
|
||||
|
@ -506,6 +506,7 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
|
||||
}
|
||||
}
|
||||
|
||||
// note: runBlocking should be used here while we are in realm single thread executor, to avoid thread switching
|
||||
private fun decryptIfNeeded(event: Event, roomId: String) = runBlocking {
|
||||
try {
|
||||
// Event from sync does not have roomId, so add it to the event first
|
||||
|
Loading…
Reference in New Issue
Block a user