mirror of
https://github.com/ouchadam/small-talk.git
synced 2025-02-16 12:10:45 +01:00
taking into account canonical room aliases
This commit is contained in:
parent
bd2dca2a41
commit
355d4a021c
@ -50,6 +50,18 @@ internal sealed class ApiTimelineEvent {
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("m.room.canonical_alias")
|
||||
internal data class CanonicalAlias(
|
||||
@SerialName("event_id") val id: EventId,
|
||||
@SerialName("content") val content: Content,
|
||||
) : ApiTimelineEvent() {
|
||||
|
||||
@Serializable
|
||||
internal data class Content(
|
||||
@SerialName("alias") val alias: String
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("m.room.avatar")
|
||||
|
@ -21,10 +21,12 @@ internal class RoomOverviewProcessor(
|
||||
null -> combinedEvents.filterIsInstance<ApiTimelineEvent.RoomCreate>().first().let { roomCreate ->
|
||||
val roomName = roomDisplayName(combinedEvents)
|
||||
val isGroup = roomToProcess.directMessage == null
|
||||
val processedName = roomName ?: roomToProcess.directMessage?.let {
|
||||
roomMembersService.find(roomToProcess.roomId, it)?.let { it.displayName ?: it.id.value }
|
||||
}
|
||||
|
||||
RoomOverview(
|
||||
roomName = roomName ?: roomToProcess.directMessage?.let {
|
||||
roomMembersService.find(roomToProcess.roomId, it)?.let { it.displayName ?: it.id.value }
|
||||
},
|
||||
roomName = processedName,
|
||||
roomCreationUtc = roomCreate.utcTimestamp,
|
||||
lastMessage = lastMessage,
|
||||
roomId = roomToProcess.roomId,
|
||||
@ -40,6 +42,7 @@ internal class RoomOverviewProcessor(
|
||||
isEncrypted = isEncrypted,
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
previousState.copy(
|
||||
roomName = previousState.roomName ?: roomDisplayName(combinedEvents),
|
||||
@ -60,7 +63,8 @@ internal class RoomOverviewProcessor(
|
||||
|
||||
private fun roomDisplayName(combinedEvents: List<ApiTimelineEvent>): String? {
|
||||
val roomName = combinedEvents.filterIsInstance<ApiTimelineEvent.RoomName>().lastOrNull()
|
||||
return roomName?.content?.name
|
||||
return (roomName?.content?.name)
|
||||
?: combinedEvents.filterIsInstance<ApiTimelineEvent.CanonicalAlias>().lastOrNull()?.content?.alias
|
||||
}
|
||||
|
||||
private suspend fun roomAvatar(
|
||||
@ -75,6 +79,7 @@ internal class RoomOverviewProcessor(
|
||||
val filterIsInstance = combinedEvents.filterIsInstance<ApiTimelineEvent.RoomAvatar>()
|
||||
filterIsInstance.lastOrNull()?.content?.url?.convertMxUrToUrl(homeServerUrl)?.let { AvatarUrl(it) }
|
||||
}
|
||||
|
||||
else -> membersService.find(roomId, dmUser)?.avatarUrl
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ internal class TimelineEventsProcessor(
|
||||
is ApiTimelineEvent.RoomMember -> null
|
||||
is ApiTimelineEvent.RoomName -> null
|
||||
is ApiTimelineEvent.RoomTopic -> null
|
||||
is ApiTimelineEvent.CanonicalAlias -> null
|
||||
ApiTimelineEvent.Ignored -> null
|
||||
}
|
||||
roomEvent
|
||||
|
Loading…
x
Reference in New Issue
Block a user