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

Device Manager: Filter sessions #6860

Merged
merged 13 commits into from
Oct 12, 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "user_other_sessions_filter.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "user_other_sessions_filter_selected.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "user_other_sessions_verified.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,18 @@ To enable access, tap Settings> Location and select Always";
"user_other_session_security_recommendation_title" = "Security recommendation";
"user_other_session_unverified_sessions_header_subtitle" = "Verify your sessions for enhanced secure messaging or sign out from those you don’t recognize or use anymore.";
"user_other_session_unverified_current_session_details" = "%@ · Your current session";

"user_other_session_verified_sessions_header_subtitle" = "For best security, sign out from any session that you don’t recognize or use anymore.";

"user_other_session_filter" = "Filter";
"user_other_session_filter_menu_all" = "All sessions";
"user_other_session_filter_menu_verified" = "Verified";
"user_other_session_filter_menu_unverified" = "Unverified";
"user_other_session_filter_menu_inactive" = "Inactive";

"user_other_session_no_inactive_sessions" = "No inactive sessions found.";
"user_other_session_no_verified_sessions" = "No verified sessions found.";
"user_other_session_no_unverified_sessions" = "No unverified sessions found.";
"user_other_session_clear_filter" = "Clear filter";
// First item is client name and second item is session display name
"user_session_name" = "%@: %@";

Expand Down
3 changes: 3 additions & 0 deletions Riot/Generated/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ internal class Asset: NSObject {
internal static let deviceTypeMobile = ImageAsset(name: "device_type_mobile")
internal static let deviceTypeUnknown = ImageAsset(name: "device_type_unknown")
internal static let deviceTypeWeb = ImageAsset(name: "device_type_web")
internal static let userOtherSessionsFilter = ImageAsset(name: "user_other_sessions_filter")
internal static let userOtherSessionsFilterSelected = ImageAsset(name: "user_other_sessions_filter_selected")
internal static let userOtherSessionsInactive = ImageAsset(name: "user_other_sessions_inactive")
internal static let userOtherSessionsUnverified = ImageAsset(name: "user_other_sessions_unverified")
internal static let userOtherSessionsVerified = ImageAsset(name: "user_other_sessions_verified")
internal static let userSessionListItemInactiveSession = ImageAsset(name: "user_session_list_item_inactive_session")
internal static let userSessionUnverified = ImageAsset(name: "user_session_unverified")
internal static let userSessionVerificationUnknown = ImageAsset(name: "user_session_verification_unknown")
Expand Down
40 changes: 40 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8635,6 +8635,42 @@ public class VectorL10n: NSObject {
public static func userInactiveSessionItemWithDate(_ p1: String) -> String {
return VectorL10n.tr("Vector", "user_inactive_session_item_with_date", p1)
}
/// Clear filter
public static var userOtherSessionClearFilter: String {
return VectorL10n.tr("Vector", "user_other_session_clear_filter")
}
/// Filter
public static var userOtherSessionFilter: String {
return VectorL10n.tr("Vector", "user_other_session_filter")
}
/// All sessions
public static var userOtherSessionFilterMenuAll: String {
return VectorL10n.tr("Vector", "user_other_session_filter_menu_all")
}
/// Inactive
public static var userOtherSessionFilterMenuInactive: String {
return VectorL10n.tr("Vector", "user_other_session_filter_menu_inactive")
}
/// Unverified
public static var userOtherSessionFilterMenuUnverified: String {
return VectorL10n.tr("Vector", "user_other_session_filter_menu_unverified")
}
/// Verified
public static var userOtherSessionFilterMenuVerified: String {
return VectorL10n.tr("Vector", "user_other_session_filter_menu_verified")
}
/// No inactive sessions found.
public static var userOtherSessionNoInactiveSessions: String {
return VectorL10n.tr("Vector", "user_other_session_no_inactive_sessions")
}
/// No unverified sessions found.
public static var userOtherSessionNoUnverifiedSessions: String {
return VectorL10n.tr("Vector", "user_other_session_no_unverified_sessions")
}
/// No verified sessions found.
public static var userOtherSessionNoVerifiedSessions: String {
return VectorL10n.tr("Vector", "user_other_session_no_verified_sessions")
}
/// Security recommendation
public static var userOtherSessionSecurityRecommendationTitle: String {
return VectorL10n.tr("Vector", "user_other_session_security_recommendation_title")
Expand All @@ -8647,6 +8683,10 @@ public class VectorL10n: NSObject {
public static var userOtherSessionUnverifiedSessionsHeaderSubtitle: String {
return VectorL10n.tr("Vector", "user_other_session_unverified_sessions_header_subtitle")
}
/// For best security, sign out from any session that you don’t recognize or use anymore.
public static var userOtherSessionVerifiedSessionsHeaderSubtitle: String {
return VectorL10n.tr("Vector", "user_other_session_verified_sessions_header_subtitle")
}
/// Name
public static var userSessionDetailsApplicationName: String {
return VectorL10n.tr("Vector", "user_session_details_application_name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final class UserSessionsFlowCoordinator: Coordinator, Presentable {
return UserSessionOverviewCoordinator(parameters: parameters)
}

private func openOtherSessions(sessionInfos: [UserSessionInfo], filterBy filter: OtherUserSessionsFilter) {
private func openOtherSessions(sessionInfos: [UserSessionInfo], filterBy filter: UserOtherSessionsFilter) {
let title = filter == .all ? VectorL10n.userSessionsOverviewOtherSessionsSectionTitle : VectorL10n.userOtherSessionSecurityRecommendationTitle
let coordinator = createOtherSessionsCoordinator(sessionInfos: sessionInfos,
filterBy: filter,
Expand All @@ -157,7 +157,7 @@ final class UserSessionsFlowCoordinator: Coordinator, Presentable {
}

private func createOtherSessionsCoordinator(sessionInfos: [UserSessionInfo],
filterBy filter: OtherUserSessionsFilter,
filterBy filter: UserOtherSessionsFilter,
title: String) -> UserOtherSessionsCoordinator {
let parameters = UserOtherSessionsCoordinatorParameters(sessionInfos: sessionInfos,
filter: filter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import SwiftUI

struct UserOtherSessionsCoordinatorParameters {
let sessionInfos: [UserSessionInfo]
let filter: OtherUserSessionsFilter
let filter: UserOtherSessionsFilter
let title: String
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
case all
case inactiveSessions
case unverifiedSessions
case verifiedSessions

/// The associated screen
var screenType: Any.Type {
Expand All @@ -36,7 +37,7 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
/// A list of screen state definitions
static var allCases: [MockUserOtherSessionsScreenState] {
// Each of the presence statuses
[.all, .inactiveSessions, .unverifiedSessions]
[.all, .inactiveSessions, .unverifiedSessions, .verifiedSessions]
}

/// Generate the view struct for the screen state.
Expand All @@ -55,6 +56,10 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
viewModel = UserOtherSessionsViewModel(sessionInfos: unverifiedSessions(),
filter: .unverified,
title: VectorL10n.userOtherSessionSecurityRecommendationTitle)
case .verifiedSessions:
viewModel = UserOtherSessionsViewModel(sessionInfos: verifiedSessions(),
filter: .verified,
title: VectorL10n.userOtherSessionSecurityRecommendationTitle)
}

// can simulate service and viewModel actions here if needs be.
Expand Down Expand Up @@ -167,6 +172,41 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
isCurrent: false)]
}

private func verifiedSessions() -> [UserSessionInfo] {
[UserSessionInfo(id: "0",
name: "iOS",
deviceType: .mobile,
verificationState: .verified,
lastSeenIP: "10.0.0.10",
lastSeenTimestamp: nil,
applicationName: nil,
applicationVersion: nil,
applicationURL: nil,
deviceModel: nil,
deviceOS: nil,
lastSeenIPLocation: nil,
clientName: nil,
clientVersion: nil,
isActive: true,
isCurrent: true),
UserSessionInfo(id: "1",
name: "macOS",
deviceType: .desktop,
verificationState: .verified,
lastSeenIP: "1.0.0.1",
lastSeenTimestamp: Date().timeIntervalSince1970 - 8_000_000,
applicationName: nil,
applicationVersion: nil,
applicationURL: nil,
deviceModel: nil,
deviceOS: nil,
lastSeenIPLocation: nil,
clientName: nil,
clientVersion: nil,
isActive: true,
isCurrent: false)]
}

private func allSessions() -> [UserSessionInfo] {
[UserSessionInfo(id: "0",
name: "iOS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UserOtherSessionsUITests: MockScreenTestCase {
func test_whenOtherSessionsWithInactiveSessionFilterPresented_correctHeaderDisplayed() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.inactiveSessions.title)

XCTAssertTrue(app.staticTexts[VectorL10n.userSessionsOverviewSecurityRecommendationsInactiveTitle].exists)
XCTAssertTrue(app.staticTexts[VectorL10n.userOtherSessionFilterMenuInactive].exists)
XCTAssertTrue(app.staticTexts[VectorL10n.userSessionsOverviewSecurityRecommendationsInactiveInfo].exists)
}

Expand All @@ -34,7 +34,7 @@ class UserOtherSessionsUITests: MockScreenTestCase {
func test_whenOtherSessionsWithUnverifiedSessionFilterPresented_correctHeaderDisplayed() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.unverifiedSessions.title)

XCTAssertTrue(app.staticTexts[VectorL10n.userSessionsOverviewSecurityRecommendationsUnverifiedTitle].exists)
XCTAssertTrue(app.staticTexts[VectorL10n.userSessionUnverifiedShort].exists)
XCTAssertTrue(app.staticTexts[VectorL10n.userOtherSessionUnverifiedSessionsHeaderSubtitle].exists)
}

Expand All @@ -49,4 +49,11 @@ class UserOtherSessionsUITests: MockScreenTestCase {

XCTAssertTrue(app.staticTexts[VectorL10n.userSessionsOverviewOtherSessionsSectionInfo].exists)
}

func test_whenOtherSessionsWithVerifiedSessionFilterPresented_correctHeaderDisplayed() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.verifiedSessions.title)

XCTAssertTrue(app.staticTexts[VectorL10n.userSessionVerifiedShort].exists)
XCTAssertTrue(app.staticTexts[VectorL10n.userOtherSessionVerifiedSessionsHeaderSubtitle].exists)
}
}
Loading