Merge pull request #2621 from element-hq/feature/bma/fixRoomCrash

fix room crash
This commit is contained in:
Benoit Marty 2024-03-28 18:44:17 +01:00 committed by GitHub
commit ce96502736
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 33 deletions

1
changelog.d/2619.bugfix Normal file
View file

@ -0,0 +1 @@
Fix crash observed when going back to the room list.

View file

@ -208,16 +208,15 @@ class RustMatrixClient(
}
}
private val rustRoomListService: RoomListService =
RustRoomListService(
override val roomListService: RoomListService = RustRoomListService(
innerRoomListService = innerRoomListService,
sessionCoroutineScope = sessionCoroutineScope,
sessionDispatcher = sessionDispatcher,
roomListFactory = RoomListFactory(
innerRoomListService = innerRoomListService,
sessionCoroutineScope = sessionCoroutineScope,
sessionDispatcher = sessionDispatcher,
roomListFactory = RoomListFactory(
innerRoomListService = innerRoomListService,
sessionCoroutineScope = sessionCoroutineScope,
),
)
),
)
private val eventFilters = TimelineEventTypeFilter.exclude(
listOf(
@ -238,12 +237,11 @@ class RustMatrixClient(
).map(FilterTimelineEventType::State)
)
override val roomListService: RoomListService
get() = rustRoomListService
private val rustMediaLoader = RustMediaLoader(baseCacheDirectory, dispatchers, client)
override val mediaLoader: MatrixMediaLoader
get() = rustMediaLoader
override val mediaLoader: MatrixMediaLoader = RustMediaLoader(
baseCacheDirectory = baseCacheDirectory,
dispatchers = dispatchers,
innerClient = client,
)
private val roomMembershipObserver = RoomMembershipObserver()

View file

@ -182,48 +182,40 @@ class RustMatrixRoom(
}
override val name: String?
get() {
return roomListItem.name()
}
get() = runCatching { roomListItem.name() }.getOrDefault(null)
override val displayName: String
get() {
return innerRoom.displayName()
}
get() = runCatching { innerRoom.displayName() }.getOrDefault("")
override val topic: String?
get() {
return innerRoom.topic()
}
get() = runCatching { innerRoom.topic() }.getOrDefault(null)
override val avatarUrl: String?
get() {
return roomListItem.avatarUrl() ?: innerRoom.avatarUrl()
}
get() = runCatching { roomListItem.avatarUrl() ?: innerRoom.avatarUrl() }.getOrDefault(null)
override val isEncrypted: Boolean
get() = runCatching { innerRoom.isEncrypted() }.getOrDefault(false)
override val alias: String?
get() = innerRoom.canonicalAlias()
get() = runCatching { innerRoom.canonicalAlias() }.getOrDefault(null)
override val alternativeAliases: List<String>
get() = innerRoom.alternativeAliases()
get() = runCatching { innerRoom.alternativeAliases() }.getOrDefault(emptyList())
override val isPublic: Boolean
get() = innerRoom.isPublic()
get() = runCatching { innerRoom.isPublic() }.getOrDefault(false)
override val isSpace: Boolean
get() = innerRoom.isSpace()
get() = runCatching { innerRoom.isSpace() }.getOrDefault(false)
override val isDirect: Boolean
get() = innerRoom.isDirect()
get() = runCatching { innerRoom.isDirect() }.getOrDefault(false)
override val joinedMemberCount: Long
get() = innerRoom.joinedMembersCount().toLong()
get() = runCatching { innerRoom.joinedMembersCount().toLong() }.getOrDefault(0)
override val activeMemberCount: Long
get() = innerRoom.activeMembersCount().toLong()
get() = runCatching { innerRoom.activeMembersCount().toLong() }.getOrDefault(0)
override suspend fun updateMembers() {
val useCache = membersStateFlow.value is MatrixRoomMembersState.Unknown