Browse Source

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

fix room crash
pull/2622/head
Benoit Marty 6 months ago committed by GitHub
parent
commit
ce96502736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      changelog.d/2619.bugfix
  2. 26
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt
  3. 30
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt

1
changelog.d/2619.bugfix

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

26
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt

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

30
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt

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

Loading…
Cancel
Save