mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
feature(space): compute space room name locally
This commit is contained in:
+13
-1
@@ -15,7 +15,7 @@ import io.element.android.libraries.matrix.api.room.join.JoinRule
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
|
||||
data class SpaceRoom(
|
||||
val name: String?,
|
||||
val rawName: String?,
|
||||
val avatarUrl: String?,
|
||||
val canonicalAlias: RoomAlias?,
|
||||
val childrenCount: Int,
|
||||
@@ -32,6 +32,18 @@ data class SpaceRoom(
|
||||
* The via parameters of the room.
|
||||
*/
|
||||
val via: List<String>,
|
||||
val isDirect: Boolean?,
|
||||
) {
|
||||
val isSpace = roomType == RoomType.Space
|
||||
|
||||
/**
|
||||
* Temporary logic to compute a name for direct rooms with no name.
|
||||
* This will be replaced by sdk logic in the future.
|
||||
*/
|
||||
val name = if (rawName == null && isDirect == true && heroes.size == 1) {
|
||||
val dmRecipient = heroes.first()
|
||||
dmRecipient.displayName
|
||||
} else {
|
||||
rawName
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,7 +24,7 @@ class SpaceRoomMapper {
|
||||
guestCanJoin = spaceRoom.guestCanJoin,
|
||||
heroes = spaceRoom.heroes.orEmpty().map { it.map() },
|
||||
joinRule = spaceRoom.joinRule?.map(),
|
||||
name = spaceRoom.name,
|
||||
rawName = spaceRoom.name,
|
||||
numJoinedMembers = spaceRoom.numJoinedMembers.toInt(),
|
||||
roomId = RoomId(spaceRoom.roomId),
|
||||
roomType = spaceRoom.roomType.map(),
|
||||
@@ -32,6 +32,7 @@ class SpaceRoomMapper {
|
||||
topic = spaceRoom.topic,
|
||||
worldReadable = spaceRoom.worldReadable.orFalse(),
|
||||
via = spaceRoom.via,
|
||||
isDirect = spaceRoom.isDirect,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user