allowing the canonical alias to be null when parsing the sync response

This commit is contained in:
Adam Brown 2022-10-02 14:14:22 +01:00 committed by Adam Brown
parent 933197dfd7
commit 95c95c38ca
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ internal sealed class ApiTimelineEvent {
@Serializable
internal data class Content(
@SerialName("alias") val alias: String
@SerialName("alias") val alias: String? = null
)
}

View File

@ -66,7 +66,7 @@ internal class RoomOverviewProcessor(
private suspend fun roomDisplayName(roomToProcess: RoomToProcess, combinedEvents: List<ApiTimelineEvent>): String? {
val roomName = combinedEvents.filterIsInstance<ApiTimelineEvent.RoomName>().lastOrNull()?.content?.name
?: combinedEvents.filterIsInstance<ApiTimelineEvent.CanonicalAlias>().lastOrNull()?.content?.alias
?: combinedEvents.filterIsInstance<ApiTimelineEvent.CanonicalAlias>().lastOrNull()?.content?.alias?.takeIf { it.isNotEmpty() }
?: roomToProcess.heroes?.let {
roomMembersService.find(roomToProcess.roomId, it).joinToString { it.displayName ?: it.id.value }
}