mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Use writeAsync for localEcho
This commit is contained in:
parent
283f32479d
commit
7434aed43f
2 changed files with 4 additions and 7 deletions
|
@ -62,7 +62,6 @@ import im.vector.matrix.android.internal.session.content.ThumbnailExtractor
|
|||
import im.vector.matrix.android.internal.session.room.send.pills.TextPillsUtils
|
||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||
import im.vector.matrix.android.internal.util.StringProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
@ -474,9 +473,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
|
||||
fun createLocalEcho(event: Event) {
|
||||
checkNotNull(event.roomId) { "Your event should have a roomId" }
|
||||
taskExecutor.executorScope.launch {
|
||||
localEchoRepository.createLocalEcho(event)
|
||||
}
|
||||
localEchoRepository.createLocalEcho(event)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -48,7 +48,7 @@ internal class LocalEchoRepository @Inject constructor(@SessionDatabase private
|
|||
private val eventBus: EventBus,
|
||||
private val timelineEventMapper: TimelineEventMapper) {
|
||||
|
||||
suspend fun createLocalEcho(event: Event) {
|
||||
fun createLocalEcho(event: Event) {
|
||||
val roomId = event.roomId ?: throw IllegalStateException("You should have set a roomId for your event")
|
||||
val senderId = event.senderId ?: throw IllegalStateException("You should have set a senderIf for your event")
|
||||
if (event.eventId == null) {
|
||||
|
@ -70,8 +70,8 @@ internal class LocalEchoRepository @Inject constructor(@SessionDatabase private
|
|||
}
|
||||
val timelineEvent = timelineEventMapper.map(timelineEventEntity)
|
||||
eventBus.post(DefaultTimeline.OnLocalEchoCreated(roomId = roomId, timelineEvent = timelineEvent))
|
||||
monarchy.awaitTransaction { realm ->
|
||||
val roomEntity = RoomEntity.where(realm, roomId = roomId).findFirst() ?: return@awaitTransaction
|
||||
monarchy.writeAsync { realm ->
|
||||
val roomEntity = RoomEntity.where(realm, roomId = roomId).findFirst() ?: return@writeAsync
|
||||
roomEntity.sendingTimelineEvents.add(0, timelineEventEntity)
|
||||
roomSummaryUpdater.update(realm, roomId)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue