diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index aa9ae992c..fc5e814c2 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -16001,7 +16001,12 @@ class SpaceRoomProxyMock: SpaceRoomProxyProtocol, @unchecked Sendable { set(value) { underlyingId = value } } var underlyingId: String! - var name: String? + var name: String { + get { return underlyingName } + set(value) { underlyingName = value } + } + var underlyingName: String! + var rawName: String? var avatarURL: URL? var isSpace: Bool { get { return underlyingIsSpace } diff --git a/ElementX/Sources/Mocks/SDK/LeaveSpaceHandleSDKMock.swift b/ElementX/Sources/Mocks/SDK/LeaveSpaceHandleSDKMock.swift index d52557fde..812bd694c 100644 --- a/ElementX/Sources/Mocks/SDK/LeaveSpaceHandleSDKMock.swift +++ b/ElementX/Sources/Mocks/SDK/LeaveSpaceHandleSDKMock.swift @@ -23,7 +23,7 @@ extension LeaveSpaceHandleSDKMock { extension [LeaveSpaceRoom] { static func mockLastSpaceAdmin(spaceRoomProxy: SpaceRoomProxyProtocol) -> [LeaveSpaceRoom] { mockRooms + [LeaveSpaceRoom(spaceRoom: SpaceRoom(id: spaceRoomProxy.id, - name: spaceRoomProxy.computedName, + name: spaceRoomProxy.name, avatarURL: spaceRoomProxy.avatarURL, isSpace: true, memberCount: UInt64(spaceRoomProxy.joinedMembersCount), diff --git a/ElementX/Sources/Mocks/SpaceRoomProxyMock.swift b/ElementX/Sources/Mocks/SpaceRoomProxyMock.swift index 84d3df2fd..8e4e4bd9f 100644 --- a/ElementX/Sources/Mocks/SpaceRoomProxyMock.swift +++ b/ElementX/Sources/Mocks/SpaceRoomProxyMock.swift @@ -12,6 +12,7 @@ extension SpaceRoomProxyMock { struct Configuration { var id: String = UUID().uuidString var name: String? + var rawName: String? var avatarURL: URL? var isSpace: Bool @@ -33,7 +34,8 @@ extension SpaceRoomProxyMock { self.init() id = configuration.id - name = configuration.name + name = configuration.name ?? configuration.id + rawName = configuration.rawName avatarURL = configuration.avatarURL isSpace = configuration.isSpace isDirect = configuration.isDirect diff --git a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift index a19291a3f..c21fb90e3 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift @@ -200,7 +200,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo } private func updateSpaceRoomDetails(spaceRoomProxy: SpaceRoomProxyProtocol, inviter: RoomInviterDetails?) async { - state.roomDetails = JoinRoomScreenRoomDetails(name: spaceRoomProxy.computedName, + state.roomDetails = JoinRoomScreenRoomDetails(name: spaceRoomProxy.name, topic: spaceRoomProxy.topic, canonicalAlias: spaceRoomProxy.canonicalAlias, avatar: spaceRoomProxy.avatar, diff --git a/ElementX/Sources/Screens/Spaces/Common/SpaceHeaderView.swift b/ElementX/Sources/Screens/Spaces/Common/SpaceHeaderView.swift index 10be90eb7..b576a757a 100644 --- a/ElementX/Sources/Screens/Spaces/Common/SpaceHeaderView.swift +++ b/ElementX/Sources/Screens/Spaces/Common/SpaceHeaderView.swift @@ -22,7 +22,7 @@ struct SpaceHeaderView: View { .accessibilityHidden(true) VStack(spacing: 8) { - Text(spaceRoomProxy.computedName) + Text(spaceRoomProxy.name) .font(.compound.headingLGBold) .foregroundStyle(.compound.textPrimary) .multilineTextAlignment(.center) diff --git a/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift b/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift index 2bef3057e..b7df75986 100644 --- a/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift +++ b/ElementX/Sources/Screens/Spaces/Common/SpaceRoomCell.swift @@ -90,7 +90,7 @@ struct SpaceRoomCell: View { private var content: some View { HStack(spacing: 16) { VStack(alignment: .leading, spacing: 2) { - Text(spaceRoomProxy.computedName) + Text(spaceRoomProxy.name) .font(.compound.bodyLGSemibold) .foregroundColor(.compound.textPrimary) .lineLimit(1) diff --git a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/LeaveSpaceRoomDetailsCell.swift b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/LeaveSpaceRoomDetailsCell.swift index 986db339f..a77643cf9 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/LeaveSpaceRoomDetailsCell.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/LeaveSpaceRoomDetailsCell.swift @@ -41,7 +41,7 @@ struct LeaveSpaceRoomDetailsCell: View { } VStack(alignment: .leading, spacing: 0) { - Text(room.spaceRoomProxy.computedName) + Text(room.spaceRoomProxy.name) .font(.compound.bodyLGSemibold) .foregroundStyle(.compound.textPrimary) .lineLimit(1) diff --git a/ElementX/Sources/Services/Spaces/SpaceRoomProxy.swift b/ElementX/Sources/Services/Spaces/SpaceRoomProxy.swift index a3454ffe9..d1e7388ba 100644 --- a/ElementX/Sources/Services/Spaces/SpaceRoomProxy.swift +++ b/ElementX/Sources/Services/Spaces/SpaceRoomProxy.swift @@ -16,7 +16,8 @@ class SpaceRoomProxy: SpaceRoomProxyProtocol { } lazy var id = spaceRoom.roomId - var name: String? { spaceRoom.displayName } + var name: String { spaceRoom.displayName } + var rawName: String? { spaceRoom.rawName } var avatarURL: URL? { spaceRoom.avatarUrl.flatMap(URL.init) } var isSpace: Bool { spaceRoom.roomType == .space } diff --git a/ElementX/Sources/Services/Spaces/SpaceRoomProxyProtocol.swift b/ElementX/Sources/Services/Spaces/SpaceRoomProxyProtocol.swift index 3cb998f9d..f8e911bc4 100644 --- a/ElementX/Sources/Services/Spaces/SpaceRoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Spaces/SpaceRoomProxyProtocol.swift @@ -18,7 +18,8 @@ enum SpaceRoomProxyVisibility: Equatable { // sourcery: AutoMockable protocol SpaceRoomProxyProtocol { var id: String { get } - var name: String? { get } + var name: String { get } + var rawName: String? { get } var avatarURL: URL? { get } var isSpace: Bool { get } @@ -48,14 +49,6 @@ extension SpaceRoomProxyProtocol { } } - var computedName: String { - if !isSpace, isDirect == true, name == nil, heroes.count == 1, let dmRecipient = heroes.first { - dmRecipient.displayName ?? dmRecipient.id - } else { - name ?? canonicalAlias ?? id - } - } - var visibility: SpaceRoomProxyVisibility? { switch joinRule { case .public: