From d5eb165d00ea9cb6233105b0895037f229ab2f54 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Fri, 30 Dec 2022 11:37:06 +0100 Subject: [PATCH 1/3] Fix display session name --- .../UserSessions/Common/UserSessionNameFormatter.swift | 4 ++-- .../UserSessions/Common/View/UserSessionCardViewData.swift | 2 +- .../View/UserSessionListItemViewDataFactory.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift b/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift index db7f2e1e6a..c39c64aba3 100644 --- a/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift +++ b/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift @@ -19,7 +19,7 @@ import Foundation /// Enables to build user session name enum UserSessionNameFormatter { /// Session name with client name and session display name - static func sessionName(deviceType: DeviceType, sessionDisplayName: String?) -> String { - sessionDisplayName?.vc_nilIfEmpty() ?? deviceType.name + static func sessionName(sessionId: String, sessionDisplayName: String?) -> String { + sessionDisplayName?.vc_nilIfEmpty() ?? sessionId } } diff --git a/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardViewData.swift b/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardViewData.swift index 79cd2d8120..7ccf63bff8 100644 --- a/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardViewData.swift +++ b/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardViewData.swift @@ -102,7 +102,7 @@ struct UserSessionCardViewData { isCurrentSessionDisplayMode: Bool = false, isActive: Bool) { self.sessionId = sessionId - sessionName = UserSessionNameFormatter.sessionName(deviceType: deviceType, sessionDisplayName: sessionDisplayName) + sessionName = UserSessionNameFormatter.sessionName(sessionId: sessionId, sessionDisplayName: sessionDisplayName) self.verificationState = verificationState var lastActivityDateString: String? diff --git a/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/View/UserSessionListItemViewDataFactory.swift b/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/View/UserSessionListItemViewDataFactory.swift index 227ed5d012..79317be71f 100644 --- a/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/View/UserSessionListItemViewDataFactory.swift +++ b/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/View/UserSessionListItemViewDataFactory.swift @@ -19,7 +19,7 @@ import Foundation struct UserSessionListItemViewDataFactory { func create(from sessionInfo: UserSessionInfo, isSelected: Bool = false) -> UserSessionListItemViewData { - let sessionName = UserSessionNameFormatter.sessionName(deviceType: sessionInfo.deviceType, + let sessionName = UserSessionNameFormatter.sessionName(sessionId: sessionInfo.id, sessionDisplayName: sessionInfo.name) let sessionDetails = buildSessionDetails(sessionInfo: sessionInfo) let deviceAvatarViewData = DeviceAvatarViewData(deviceType: sessionInfo.deviceType, From 61e2b6625f95de47bb5231feed8891c1a9ab8f2b Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Fri, 30 Dec 2022 11:46:15 +0100 Subject: [PATCH 2/3] Add changelog.d file --- changelog.d/pr-7214.change | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-7214.change diff --git a/changelog.d/pr-7214.change b/changelog.d/pr-7214.change new file mode 100644 index 0000000000..e0b5e1f44b --- /dev/null +++ b/changelog.d/pr-7214.change @@ -0,0 +1 @@ +Device Manager: change fallback display name for sessions. From 8de1d2a53aa01b2d05bc1334e9496b30179b3ee9 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Fri, 30 Dec 2022 12:13:56 +0100 Subject: [PATCH 3/3] Fix UTs --- .../Common/Test/Unit/UserSessionNameFormatterTests.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift b/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift index c40bb2fa35..a3703ef549 100644 --- a/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift +++ b/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift @@ -20,14 +20,14 @@ import XCTest class UserSessionNameFormatterTests: XCTestCase { func testSessionDisplayNameTrumpsDeviceTypeName() { - XCTAssertEqual("Johnny's iPhone", UserSessionNameFormatter.sessionName(deviceType: .mobile, sessionDisplayName: "Johnny's iPhone")) + XCTAssertEqual("Johnny's iPhone", UserSessionNameFormatter.sessionName(sessionId: "sessionId", sessionDisplayName: "Johnny's iPhone")) } func testEmptySessionDisplayNameFallsBackToDeviceTypeName() { - XCTAssertEqual(DeviceType.mobile.name, UserSessionNameFormatter.sessionName(deviceType: .mobile, sessionDisplayName: "")) + XCTAssertEqual("sessionId", UserSessionNameFormatter.sessionName(sessionId: "sessionId", sessionDisplayName: "")) } func testNilSessionDisplayNameFallsBackToDeviceTypeName() { - XCTAssertEqual(DeviceType.mobile.name, UserSessionNameFormatter.sessionName(deviceType: .mobile, sessionDisplayName: nil)) + XCTAssertEqual("sessionId", UserSessionNameFormatter.sessionName(sessionId: "sessionId", sessionDisplayName: nil)) } }