Some clean up on room details

This commit is contained in:
ganfra 2023-04-12 12:22:13 +02:00
parent 7a247e1c29
commit 281f90e148
7 changed files with 37 additions and 71 deletions

View file

@ -56,5 +56,5 @@ interface MatrixRoom: Closeable {
suspend fun redactEvent(eventId: EventId, reason: String? = null): Result<Unit>
fun leave(): Result<Unit>
suspend fun leave(): Result<Unit>
}

View file

@ -88,6 +88,7 @@ class RustMatrixRoom(
coroutineDispatchers = coroutineDispatchers
)
}
override fun close() {
innerRoom.destroy()
slidingSyncRoom.destroy()
@ -183,7 +184,9 @@ class RustMatrixRoom(
}
}
override fun leave(): Result<Unit> {
return runCatching { innerRoom.leave() }
override suspend fun leave(): Result<Unit> = withContext(coroutineDispatchers.io) {
runCatching {
innerRoom.leave()
}
}
}

View file

@ -117,7 +117,7 @@ class FakeMatrixRoom(
return Result.success(Unit)
}
override fun leave(): Result<Unit> = leaveRoomError?.let { Result.failure(it) } ?: Result.success(Unit)
override suspend fun leave(): Result<Unit> = leaveRoomError?.let { Result.failure(it) } ?: Result.success(Unit)
override fun close() = Unit