Device Manager: Rename Session (#6826)

* Publish the user sessions overview data.
* Add UserSessionName screen.
* Update logout action to match Figma more closely.
This commit is contained in:
Doug
2022-10-11 13:11:15 +01:00
committed by GitHub
parent 969c51db1e
commit efaf98fe6a
29 changed files with 765 additions and 123 deletions
@@ -14,7 +14,7 @@
// limitations under the License.
//
import Foundation
import Combine
class MockUserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
enum Mode {
@@ -27,17 +27,17 @@ class MockUserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
private let mode: Mode
var overviewData: UserSessionsOverviewData
var overviewDataPublisher: CurrentValueSubject<UserSessionsOverviewData, Never>
var sessionInfos = [UserSessionInfo]()
init(mode: Mode = .currentSessionUnverified) {
self.mode = mode
overviewData = UserSessionsOverviewData(currentSession: nil,
unverifiedSessions: [],
inactiveSessions: [],
otherSessions: [],
linkDeviceEnabled: false)
overviewDataPublisher = .init(UserSessionsOverviewData(currentSession: nil,
unverifiedSessions: [],
inactiveSessions: [],
otherSessions: [],
linkDeviceEnabled: false))
}
func updateOverviewData(completion: @escaping (Result<UserSessionsOverviewData, Error>) -> Void) {
@@ -46,43 +46,43 @@ class MockUserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
switch mode {
case .noOtherSessions:
overviewData = UserSessionsOverviewData(currentSession: currentSession,
unverifiedSessions: [],
inactiveSessions: [],
otherSessions: [],
linkDeviceEnabled: false)
overviewDataPublisher.send(UserSessionsOverviewData(currentSession: mockCurrentSession,
unverifiedSessions: [],
inactiveSessions: [],
otherSessions: [],
linkDeviceEnabled: false))
case .onlyUnverifiedSessions:
overviewData = UserSessionsOverviewData(currentSession: currentSession,
unverifiedSessions: unverifiedSessions + [currentSession],
inactiveSessions: [],
otherSessions: unverifiedSessions,
linkDeviceEnabled: false)
overviewDataPublisher.send(UserSessionsOverviewData(currentSession: mockCurrentSession,
unverifiedSessions: unverifiedSessions + [mockCurrentSession],
inactiveSessions: [],
otherSessions: unverifiedSessions,
linkDeviceEnabled: false))
case .onlyInactiveSessions:
overviewData = UserSessionsOverviewData(currentSession: currentSession,
unverifiedSessions: [],
inactiveSessions: inactiveSessions,
otherSessions: inactiveSessions,
linkDeviceEnabled: false)
overviewDataPublisher.send(UserSessionsOverviewData(currentSession: mockCurrentSession,
unverifiedSessions: [],
inactiveSessions: inactiveSessions,
otherSessions: inactiveSessions,
linkDeviceEnabled: false))
default:
let otherSessions = unverifiedSessions + inactiveSessions + buildSessions(verified: true, active: true)
overviewData = UserSessionsOverviewData(currentSession: currentSession,
unverifiedSessions: unverifiedSessions,
inactiveSessions: inactiveSessions,
otherSessions: otherSessions,
linkDeviceEnabled: true)
overviewDataPublisher.send(UserSessionsOverviewData(currentSession: mockCurrentSession,
unverifiedSessions: unverifiedSessions,
inactiveSessions: inactiveSessions,
otherSessions: otherSessions,
linkDeviceEnabled: true))
}
completion(.success(overviewData))
completion(.success(overviewDataPublisher.value))
}
func sessionForIdentifier(_ sessionId: String) -> UserSessionInfo? {
overviewData.otherSessions.first { $0.id == sessionId }
otherSessions.first { $0.id == sessionId }
}
// MARK: - Private
// MARK: - Private
private var currentSession: UserSessionInfo {
private var mockCurrentSession: UserSessionInfo {
UserSessionInfo(id: "alice",
name: "iOS",
deviceType: .mobile,