Add some missing runCatching to protect innerRoom access.

May fix https://sentry.tools.element.io/organizations/element/issues/533226/events/e22d3a80ab204ce392e65c989c2753ac/
This commit is contained in:
Benoit Marty
2024-09-24 16:13:39 +02:00
parent 72ca2f9eb0
commit 8b161bf72c

View File

@@ -105,8 +105,12 @@ class RustMatrixRoom(
override val roomInfoFlow: Flow<MatrixRoomInfo> = mxCallbackFlow {
launch {
val initial = innerRoom.roomInfo().let(matrixRoomInfoMapper::map)
channel.trySend(initial)
runCatching { innerRoom.roomInfo() }
.getOrNull()
?.let(matrixRoomInfoMapper::map)
?.let { initial ->
channel.trySend(initial)
}
}
innerRoom.subscribeToRoomInfoUpdates(object : RoomInfoListener {
override fun call(roomInfo: RoomInfo) {
@@ -623,9 +627,13 @@ class RustMatrixRoom(
innerRoom.sendCallNotificationIfNeeded()
}
override suspend fun setSendQueueEnabled(enabled: Boolean) = withContext(roomDispatcher) {
Timber.d("setSendQueuesEnabled: $enabled")
innerRoom.enableSendQueue(enabled)
override suspend fun setSendQueueEnabled(enabled: Boolean) {
withContext(roomDispatcher) {
Timber.d("setSendQueuesEnabled: $enabled")
runCatching {
innerRoom.enableSendQueue(enabled)
}
}
}
override suspend fun saveComposerDraft(composerDraft: ComposerDraft): Result<Unit> = runCatching {