Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change display name fallback for sessions #7214

Merged
merged 3 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-7214.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Device Manager: change fallback display name for sessions.