From 42f7934f74a065d2e05b0f46533fbd26a2124168 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 09:48:17 +0200 Subject: [PATCH 1/8] Only use device type name as fallback for session display name --- Riot/Assets/de.lproj/Vector.strings | 2 -- Riot/Assets/en.lproj/Vector.strings | 3 -- Riot/Assets/et.lproj/Vector.strings | 2 -- Riot/Assets/hu.lproj/Vector.strings | 2 -- Riot/Assets/id.lproj/Vector.strings | 2 -- Riot/Assets/is.lproj/Vector.strings | 2 -- Riot/Assets/it.lproj/Vector.strings | 2 -- Riot/Assets/pt_BR.lproj/Vector.strings | 2 -- Riot/Assets/sk.lproj/Vector.strings | 2 -- Riot/Assets/uk.lproj/Vector.strings | 2 -- Riot/Categories/String.swift | 5 +++ Riot/Generated/Strings.swift | 4 --- .../Unit/UserSessionNameFormatterTests.swift | 33 +++++++++++++++++++ .../Common/UserSessionNameFormatter.swift | 12 +------ RiotTests/String+Element.swift | 6 ++++ 15 files changed, 45 insertions(+), 36 deletions(-) create mode 100644 RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift diff --git a/Riot/Assets/de.lproj/Vector.strings b/Riot/Assets/de.lproj/Vector.strings index 1942aa352d..77c7cb3d19 100644 --- a/Riot/Assets/de.lproj/Vector.strings +++ b/Riot/Assets/de.lproj/Vector.strings @@ -2494,8 +2494,6 @@ "spaces_creation_new_rooms_message" = "Wir werden für jedes Thema einen Raum erstellen."; "create_room_section_footer_type_public" = "Sichtbar und betretbar für alle eingeladenen Personen, nicht nur jene, die sich im Space befinden."; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "existing" = "Bestehend"; "device_name_web" = "%@ Web"; "spaces_subspace_creation_visibility_title" = "Welche Art von Subspace möchtest du erstellen?"; diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 0b5f402fc6..aed0a6e697 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -2394,9 +2394,6 @@ To enable access, tap Settings> Location and select Always"; "user_other_session_security_recommendation_title" = "Security recommendation"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; - "user_session_item_details" = "%@ · Last activity %@"; "user_inactive_session_item" = "Inactive for 90+ days"; "user_inactive_session_item_with_date" = "Inactive for 90+ days (%@)"; diff --git a/Riot/Assets/et.lproj/Vector.strings b/Riot/Assets/et.lproj/Vector.strings index d84210c12f..f12ea09575 100644 --- a/Riot/Assets/et.lproj/Vector.strings +++ b/Riot/Assets/et.lproj/Vector.strings @@ -2443,8 +2443,6 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Viimati kasutusel %@"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Turvalise sõnumivahetuse nimel palun verifitseeri oma praegune sessioon."; "user_session_verified_additional_info" = "Sinu praegune sessioon on valmis turvaliseks sõnumivahetuseks."; "user_session_learn_more" = "Loe lisateavet"; diff --git a/Riot/Assets/hu.lproj/Vector.strings b/Riot/Assets/hu.lproj/Vector.strings index 87b74c5bb6..452f66b275 100644 --- a/Riot/Assets/hu.lproj/Vector.strings +++ b/Riot/Assets/hu.lproj/Vector.strings @@ -2491,8 +2491,6 @@ "device_name_web" = "%@ Web"; "user_session_item_details" = "%@ · Utolsó aktivitás %@"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Az aktuális munkamenet készen áll a biztonságos üzenetküldésre."; "user_session_verified_additional_info" = "Az aktuális munkamenet készen áll a biztonságos üzenetküldésre."; "user_session_learn_more" = "Tudj meg többet"; diff --git a/Riot/Assets/id.lproj/Vector.strings b/Riot/Assets/id.lproj/Vector.strings index d698f61150..fd2e0655d5 100644 --- a/Riot/Assets/id.lproj/Vector.strings +++ b/Riot/Assets/id.lproj/Vector.strings @@ -2698,8 +2698,6 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Aktivitas terakhir %@"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Verifikasi sesi Anda saat ini untuk perpesanan aman yang baik."; "user_session_verified_additional_info" = "Sesi Anda saat ini siap untuk perpesanan aman."; "user_session_learn_more" = "Pelajari lebih lanjut"; diff --git a/Riot/Assets/is.lproj/Vector.strings b/Riot/Assets/is.lproj/Vector.strings index ad9ba1194b..b32c9663eb 100644 --- a/Riot/Assets/is.lproj/Vector.strings +++ b/Riot/Assets/is.lproj/Vector.strings @@ -2118,8 +2118,6 @@ "store_short_description" = "Öruggt dreifvinnsluspjall/VoIP"; "device_name_unknown" = "Óþekkt forrit (biðlari)"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_learn_more" = "Kanna nánar"; "user_session_view_details" = "Skoða nánar"; "user_session_verify_action" = "Sannprófa setu"; diff --git a/Riot/Assets/it.lproj/Vector.strings b/Riot/Assets/it.lproj/Vector.strings index ec31cebb3a..bd21879ac5 100644 --- a/Riot/Assets/it.lproj/Vector.strings +++ b/Riot/Assets/it.lproj/Vector.strings @@ -2471,8 +2471,6 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Ultima attività %@"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Verifica la tua sessione attuale per messaggi più sicuri."; "user_session_verified_additional_info" = "La tua sessione attuale è pronta per i messaggi sicuri."; "user_session_learn_more" = "Maggiori informazioni"; diff --git a/Riot/Assets/pt_BR.lproj/Vector.strings b/Riot/Assets/pt_BR.lproj/Vector.strings index 362dd96206..1c9d803e97 100644 --- a/Riot/Assets/pt_BR.lproj/Vector.strings +++ b/Riot/Assets/pt_BR.lproj/Vector.strings @@ -2472,8 +2472,6 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Última atividade %@"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Verifique sua sessão atual para mensageria segura melhorada."; "user_session_verified_additional_info" = "Sua sessão atual está pronta para mensageria segura."; "user_session_learn_more" = "Saber mais"; diff --git a/Riot/Assets/sk.lproj/Vector.strings b/Riot/Assets/sk.lproj/Vector.strings index 5cecf24a5b..f503de09aa 100644 --- a/Riot/Assets/sk.lproj/Vector.strings +++ b/Riot/Assets/sk.lproj/Vector.strings @@ -2694,8 +2694,6 @@ "device_name_desktop" = "%@ Stolný počítač"; "user_session_item_details" = "%@ · Posledná aktivita %@"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Overte svoju aktuálnu reláciu pre vylepšené bezpečné zasielanie správ."; "user_session_verified_additional_info" = "Vaša aktuálna relácia je pripravená na bezpečné zasielanie správ."; "user_session_learn_more" = "Zistiť viac"; diff --git a/Riot/Assets/uk.lproj/Vector.strings b/Riot/Assets/uk.lproj/Vector.strings index 4d561fe3d9..a264062f97 100644 --- a/Riot/Assets/uk.lproj/Vector.strings +++ b/Riot/Assets/uk.lproj/Vector.strings @@ -2696,8 +2696,6 @@ "device_name_desktop" = "%@ Комп'ютер"; "user_session_item_details" = "%@ · Остання активність %@"; -// First item is client name and second item is session display name -"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Звірте свій поточний сеанс для посилення безпеки обміну повідомленнями."; "user_session_verified_additional_info" = "Ваш поточний сеанс готовий до безпечного обміну повідомленнями."; "user_session_learn_more" = "Докладніше"; diff --git a/Riot/Categories/String.swift b/Riot/Categories/String.swift index a6e48d0aa8..3379234933 100644 --- a/Riot/Categories/String.swift +++ b/Riot/Categories/String.swift @@ -63,6 +63,11 @@ extension String { func vc_reversed() -> String { return String(self.reversed()) } + + /// Returns nil if the string is empty or the string itself otherwise + func vc_nilIfEmpty() -> String? { + isEmpty ? nil : self + } } extension Optional where Wrapped == String { diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 400ebec19d..ee81b2b734 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -8575,10 +8575,6 @@ public class VectorL10n: NSObject { public static var userSessionLearnMore: String { return VectorL10n.tr("Vector", "user_session_learn_more") } - /// %@: %@ - public static func userSessionName(_ p1: String, _ p2: String) -> String { - return VectorL10n.tr("Vector", "user_session_name", p1, p2) - } /// Current session public static var userSessionOverviewCurrentSessionTitle: String { return VectorL10n.tr("Vector", "user_session_overview_current_session_title") diff --git a/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift b/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift new file mode 100644 index 0000000000..e92b6669fc --- /dev/null +++ b/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift @@ -0,0 +1,33 @@ +// +// Copyright 2021 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import XCTest + +@testable import RiotSwiftUI + +class UserSessionNameFormatterTests: XCTestCase { + func testSessionDisplayNameTrumpsDeviceTypeName() { + XCTAssertEqual("Johnny's iPhone", UserSessionNameFormatter.sessionName(deviceType: .mobile, sessionDisplayName: "Johnny's iPhone")) + } + + func testEmptySessionDisplayNameFallsBackToDeviceTypeName() { + XCTAssertEqual(DeviceType.mobile.name, UserSessionNameFormatter.sessionName(deviceType: .mobile, sessionDisplayName: "")) + } + + func testNilSessionDisplayNameFallsBackToDeviceTypeName() { + XCTAssertEqual(DeviceType.mobile.name, UserSessionNameFormatter.sessionName(deviceType: .mobile, sessionDisplayName: nil)) + } +} diff --git a/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift b/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift index 492e272261..db7f2e1e6a 100644 --- a/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift +++ b/RiotSwiftUI/Modules/UserSessions/Common/UserSessionNameFormatter.swift @@ -20,16 +20,6 @@ import Foundation enum UserSessionNameFormatter { /// Session name with client name and session display name static func sessionName(deviceType: DeviceType, sessionDisplayName: String?) -> String { - let sessionName: String - - let clientName = deviceType.name - - if let sessionDisplayName = sessionDisplayName { - sessionName = VectorL10n.userSessionName(clientName, sessionDisplayName) - } else { - sessionName = clientName - } - - return sessionName + sessionDisplayName?.vc_nilIfEmpty() ?? deviceType.name } } diff --git a/RiotTests/String+Element.swift b/RiotTests/String+Element.swift index fdf45f44cd..c532e37c07 100644 --- a/RiotTests/String+Element.swift +++ b/RiotTests/String+Element.swift @@ -45,4 +45,10 @@ class String_Element: XCTestCase { let string3 = "ab" XCTAssertEqual(string3.vc_reversed(), "ba") } + + func testNilIfEmpty() { + XCTAssertNil("".vc_nilIfEmpty()) + XCTAssertNotNil(" ".vc_nilIfEmpty()) + XCTAssertNotNil("Johnny was here".vc_nilIfEmpty()) + } } From a47abf97dd30cf72419a617ee0a3118a74ca6afc Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 09:51:35 +0200 Subject: [PATCH 2/8] Add changelog --- changelog.d/6820.change | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6820.change diff --git a/changelog.d/6820.change b/changelog.d/6820.change new file mode 100644 index 0000000000..b41cd857e7 --- /dev/null +++ b/changelog.d/6820.change @@ -0,0 +1 @@ + Only use device type name as fallback for session display name From 31a7b106da3620d574c09fc76aaf80eba7bfaf82 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 10:12:09 +0200 Subject: [PATCH 3/8] Revert translation changes --- Riot/Assets/de.lproj/Vector.strings | 2 ++ Riot/Assets/et.lproj/Vector.strings | 2 ++ Riot/Assets/hu.lproj/Vector.strings | 2 ++ Riot/Assets/id.lproj/Vector.strings | 2 ++ Riot/Assets/is.lproj/Vector.strings | 2 ++ Riot/Assets/it.lproj/Vector.strings | 2 ++ Riot/Assets/pt_BR.lproj/Vector.strings | 2 ++ Riot/Assets/sk.lproj/Vector.strings | 2 ++ Riot/Assets/uk.lproj/Vector.strings | 2 ++ 9 files changed, 18 insertions(+) diff --git a/Riot/Assets/de.lproj/Vector.strings b/Riot/Assets/de.lproj/Vector.strings index 77c7cb3d19..1942aa352d 100644 --- a/Riot/Assets/de.lproj/Vector.strings +++ b/Riot/Assets/de.lproj/Vector.strings @@ -2494,6 +2494,8 @@ "spaces_creation_new_rooms_message" = "Wir werden für jedes Thema einen Raum erstellen."; "create_room_section_footer_type_public" = "Sichtbar und betretbar für alle eingeladenen Personen, nicht nur jene, die sich im Space befinden."; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "existing" = "Bestehend"; "device_name_web" = "%@ Web"; "spaces_subspace_creation_visibility_title" = "Welche Art von Subspace möchtest du erstellen?"; diff --git a/Riot/Assets/et.lproj/Vector.strings b/Riot/Assets/et.lproj/Vector.strings index f12ea09575..d84210c12f 100644 --- a/Riot/Assets/et.lproj/Vector.strings +++ b/Riot/Assets/et.lproj/Vector.strings @@ -2443,6 +2443,8 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Viimati kasutusel %@"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Turvalise sõnumivahetuse nimel palun verifitseeri oma praegune sessioon."; "user_session_verified_additional_info" = "Sinu praegune sessioon on valmis turvaliseks sõnumivahetuseks."; "user_session_learn_more" = "Loe lisateavet"; diff --git a/Riot/Assets/hu.lproj/Vector.strings b/Riot/Assets/hu.lproj/Vector.strings index 452f66b275..87b74c5bb6 100644 --- a/Riot/Assets/hu.lproj/Vector.strings +++ b/Riot/Assets/hu.lproj/Vector.strings @@ -2491,6 +2491,8 @@ "device_name_web" = "%@ Web"; "user_session_item_details" = "%@ · Utolsó aktivitás %@"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Az aktuális munkamenet készen áll a biztonságos üzenetküldésre."; "user_session_verified_additional_info" = "Az aktuális munkamenet készen áll a biztonságos üzenetküldésre."; "user_session_learn_more" = "Tudj meg többet"; diff --git a/Riot/Assets/id.lproj/Vector.strings b/Riot/Assets/id.lproj/Vector.strings index fd2e0655d5..d698f61150 100644 --- a/Riot/Assets/id.lproj/Vector.strings +++ b/Riot/Assets/id.lproj/Vector.strings @@ -2698,6 +2698,8 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Aktivitas terakhir %@"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Verifikasi sesi Anda saat ini untuk perpesanan aman yang baik."; "user_session_verified_additional_info" = "Sesi Anda saat ini siap untuk perpesanan aman."; "user_session_learn_more" = "Pelajari lebih lanjut"; diff --git a/Riot/Assets/is.lproj/Vector.strings b/Riot/Assets/is.lproj/Vector.strings index b32c9663eb..ad9ba1194b 100644 --- a/Riot/Assets/is.lproj/Vector.strings +++ b/Riot/Assets/is.lproj/Vector.strings @@ -2118,6 +2118,8 @@ "store_short_description" = "Öruggt dreifvinnsluspjall/VoIP"; "device_name_unknown" = "Óþekkt forrit (biðlari)"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_learn_more" = "Kanna nánar"; "user_session_view_details" = "Skoða nánar"; "user_session_verify_action" = "Sannprófa setu"; diff --git a/Riot/Assets/it.lproj/Vector.strings b/Riot/Assets/it.lproj/Vector.strings index bd21879ac5..ec31cebb3a 100644 --- a/Riot/Assets/it.lproj/Vector.strings +++ b/Riot/Assets/it.lproj/Vector.strings @@ -2471,6 +2471,8 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Ultima attività %@"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Verifica la tua sessione attuale per messaggi più sicuri."; "user_session_verified_additional_info" = "La tua sessione attuale è pronta per i messaggi sicuri."; "user_session_learn_more" = "Maggiori informazioni"; diff --git a/Riot/Assets/pt_BR.lproj/Vector.strings b/Riot/Assets/pt_BR.lproj/Vector.strings index 1c9d803e97..362dd96206 100644 --- a/Riot/Assets/pt_BR.lproj/Vector.strings +++ b/Riot/Assets/pt_BR.lproj/Vector.strings @@ -2472,6 +2472,8 @@ "device_name_desktop" = "%@ Desktop"; "user_session_item_details" = "%@ · Última atividade %@"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Verifique sua sessão atual para mensageria segura melhorada."; "user_session_verified_additional_info" = "Sua sessão atual está pronta para mensageria segura."; "user_session_learn_more" = "Saber mais"; diff --git a/Riot/Assets/sk.lproj/Vector.strings b/Riot/Assets/sk.lproj/Vector.strings index f503de09aa..5cecf24a5b 100644 --- a/Riot/Assets/sk.lproj/Vector.strings +++ b/Riot/Assets/sk.lproj/Vector.strings @@ -2694,6 +2694,8 @@ "device_name_desktop" = "%@ Stolný počítač"; "user_session_item_details" = "%@ · Posledná aktivita %@"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Overte svoju aktuálnu reláciu pre vylepšené bezpečné zasielanie správ."; "user_session_verified_additional_info" = "Vaša aktuálna relácia je pripravená na bezpečné zasielanie správ."; "user_session_learn_more" = "Zistiť viac"; diff --git a/Riot/Assets/uk.lproj/Vector.strings b/Riot/Assets/uk.lproj/Vector.strings index a264062f97..4d561fe3d9 100644 --- a/Riot/Assets/uk.lproj/Vector.strings +++ b/Riot/Assets/uk.lproj/Vector.strings @@ -2696,6 +2696,8 @@ "device_name_desktop" = "%@ Комп'ютер"; "user_session_item_details" = "%@ · Остання активність %@"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; "user_session_unverified_additional_info" = "Звірте свій поточний сеанс для посилення безпеки обміну повідомленнями."; "user_session_verified_additional_info" = "Ваш поточний сеанс готовий до безпечного обміну повідомленнями."; "user_session_learn_more" = "Докладніше"; From 2554b275c4f39412eadc79f527b388e0696b9d20 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 10:14:41 +0200 Subject: [PATCH 4/8] Fix copyright year --- .../Common/Test/Unit/UserSessionNameFormatterTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift b/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift index e92b6669fc..c40bb2fa35 100644 --- a/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift +++ b/RiotSwiftUI/Modules/UserSessions/Common/Test/Unit/UserSessionNameFormatterTests.swift @@ -1,5 +1,5 @@ // -// Copyright 2021 New Vector Ltd +// Copyright 2022 New Vector Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From 82ce34c3005d960b94c94e90b1546a5d8f109e86 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 12:05:22 +0200 Subject: [PATCH 5/8] Bring back English string for now to unbreak the build --- Riot/Assets/en.lproj/Vector.strings | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index aed0a6e697..0b5f402fc6 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -2394,6 +2394,9 @@ To enable access, tap Settings> Location and select Always"; "user_other_session_security_recommendation_title" = "Security recommendation"; +// First item is client name and second item is session display name +"user_session_name" = "%@: %@"; + "user_session_item_details" = "%@ · Last activity %@"; "user_inactive_session_item" = "Inactive for 90+ days"; "user_inactive_session_item_with_date" = "Inactive for 90+ days (%@)"; From 98c5bad12d46548388747989e33ed9716d38a959 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 15:44:21 +0200 Subject: [PATCH 6/8] Remove prefix from tests --- .../UserOtherSessions/Test/UI/UserOtherSessionsUITests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/Test/UI/UserOtherSessionsUITests.swift b/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/Test/UI/UserOtherSessionsUITests.swift index 6f73638471..dec49f4459 100644 --- a/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/Test/UI/UserOtherSessionsUITests.swift +++ b/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/Test/UI/UserOtherSessionsUITests.swift @@ -28,7 +28,7 @@ class UserOtherSessionsUITests: MockScreenTestCase { func test_whenOtherSessionsWithInactiveSessionFilterPresented_correctItemsDisplayed() { app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.inactiveSessions.title) - XCTAssertTrue(app.buttons["RiotSwiftUI Mobile: iOS, Inactive for 90+ days"].exists) + XCTAssertTrue(app.buttons["iOS, Inactive for 90+ days"].exists) } func test_whenOtherSessionsWithUnverifiedSessionFilterPresented_correctHeaderDisplayed() { @@ -41,6 +41,6 @@ class UserOtherSessionsUITests: MockScreenTestCase { func test_whenOtherSessionsWithUnverifiedSessionFilterPresented_correctItemsDisplayed() { app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.unverifiedSessions.title) - XCTAssertTrue(app.buttons["RiotSwiftUI Mobile: iOS, Unverified · Your current session"].exists) + XCTAssertTrue(app.buttons["iOS, Unverified · Your current session"].exists) } } From ec42bdecbb16531bf9c1d2d7181e04656cd44aa3 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 15:57:55 +0200 Subject: [PATCH 7/8] Add back generated user session name string --- Riot/Generated/Strings.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 26e3c76ee5..0d4e4ac192 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -8687,6 +8687,10 @@ public class VectorL10n: NSObject { public static var userSessionLearnMore: String { return VectorL10n.tr("Vector", "user_session_learn_more") } + /// %@: %@ + public static func userSessionName(_ p1: String, _ p2: String) -> String { + return VectorL10n.tr("Vector", "user_session_name", p1, p2) + } /// Current session public static var userSessionOverviewCurrentSessionTitle: String { return VectorL10n.tr("Vector", "user_session_overview_current_session_title") From 4eb7a36447440186810af129c9a5ff58b4ceeb26 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 7 Oct 2022 16:02:14 +0200 Subject: [PATCH 8/8] Remove current app name from device type name --- Riot/Assets/en.lproj/Vector.strings | 5 +++++ Riot/Generated/Strings.swift | 16 ++++++++++++++++ .../Modules/UserSessions/Common/DeviceType.swift | 10 ++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 415b5b52e4..f4c79b7a68 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -2441,6 +2441,11 @@ To enable access, tap Settings> Location and select Always"; "device_name_mobile" = "%@ Mobile"; "device_name_unknown" = "Unknown client"; +"device_type_name_desktop" = "Desktop"; +"device_type_name_web" = "Web"; +"device_type_name_mobile" = "Mobile"; +"device_type_name_unknown" = "Unknown"; + "user_session_details_title" = "Session details"; "user_session_details_session_section_header" = "Session"; "user_session_details_application_section_header" = "Application"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 0d4e4ac192..ff14b2f0e5 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -1575,6 +1575,22 @@ public class VectorL10n: NSObject { public static func deviceNameWeb(_ p1: String) -> String { return VectorL10n.tr("Vector", "device_name_web", p1) } + /// Desktop + public static var deviceTypeNameDesktop: String { + return VectorL10n.tr("Vector", "device_type_name_desktop") + } + /// Mobile + public static var deviceTypeNameMobile: String { + return VectorL10n.tr("Vector", "device_type_name_mobile") + } + /// Unknown + public static var deviceTypeNameUnknown: String { + return VectorL10n.tr("Vector", "device_type_name_unknown") + } + /// Web + public static var deviceTypeNameWeb: String { + return VectorL10n.tr("Vector", "device_type_name_web") + } /// The other party cancelled the verification. public static var deviceVerificationCancelled: String { return VectorL10n.tr("Vector", "device_verification_cancelled") diff --git a/RiotSwiftUI/Modules/UserSessions/Common/DeviceType.swift b/RiotSwiftUI/Modules/UserSessions/Common/DeviceType.swift index 0f0685778a..f3b003ff3a 100644 --- a/RiotSwiftUI/Modules/UserSessions/Common/DeviceType.swift +++ b/RiotSwiftUI/Modules/UserSessions/Common/DeviceType.swift @@ -38,17 +38,15 @@ enum DeviceType { } var name: String { - let appName = AppInfo.current.displayName - switch self { case .desktop: - return VectorL10n.deviceNameDesktop(appName) + return VectorL10n.deviceTypeNameDesktop case .web: - return VectorL10n.deviceNameWeb(appName) + return VectorL10n.deviceTypeNameWeb case .mobile: - return VectorL10n.deviceNameMobile(appName) + return VectorL10n.deviceTypeNameMobile case .unknown: - return VectorL10n.deviceNameUnknown + return VectorL10n.deviceTypeNameUnknown } } }