Fix crash when calling Room.predecessorRoom when the room is destroyed (#5894)

* Fix crash when calling `Client.predecessorRoom` when the room is destroyed

* Handle the root cause of this crash: destroying the room on activity recreation
This commit is contained in:
Jorge Martin Espinosa 2025-12-15 10:25:08 +01:00 committed by GitHub
parent a571996ff3
commit aa061f8ef3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View file

@ -85,7 +85,9 @@ class RustBaseRoom(
}.stateIn(roomCoroutineScope, started = SharingStarted.Lazily, initialValue = initialRoomInfo)
override fun predecessorRoom(): PredecessorRoom? {
return innerRoom.predecessorRoom()?.map()
return runCatchingExceptions { innerRoom.predecessorRoom()?.map() }
.onFailure { Timber.e(it, "Could not get predecessor room") }
.getOrNull()
}
override suspend fun subscribeToSync() = roomSyncSubscriber.subscribe(roomId)