Switch the app to the real passport enrollment, dashboard, device, alert, and challenge APIs so it can pair with idp.global and act on server-backed state instead of demo data.
This commit is contained in:
@@ -231,27 +231,31 @@ struct NotificationCenterView: View {
|
||||
|
||||
struct DevicesView: View {
|
||||
@ObservedObject var model: AppViewModel
|
||||
@State private var isPairingCodePresented = false
|
||||
|
||||
private var devices: [DevicePresentation] {
|
||||
guard let session else { return [] }
|
||||
|
||||
let current = DevicePresentation(
|
||||
name: session.deviceName,
|
||||
systemImage: symbolName(for: session.deviceName),
|
||||
lastSeen: .now,
|
||||
isCurrent: true,
|
||||
isTrusted: true
|
||||
)
|
||||
if !model.devices.isEmpty {
|
||||
return model.devices.map { device in
|
||||
DevicePresentation(
|
||||
name: device.label,
|
||||
systemImage: symbolName(for: device.label),
|
||||
lastSeen: device.lastSeenAt ?? session.pairedAt,
|
||||
isCurrent: device.isCurrent,
|
||||
isTrusted: true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
let others = [
|
||||
DevicePresentation(name: "Phil's iPad Pro", systemImage: "ipad", lastSeen: .now.addingTimeInterval(-60 * 18), isCurrent: false, isTrusted: true),
|
||||
DevicePresentation(name: "Berlin MacBook Pro", systemImage: "laptopcomputer", lastSeen: .now.addingTimeInterval(-60 * 74), isCurrent: false, isTrusted: true),
|
||||
DevicePresentation(name: "Apple Watch", systemImage: "applewatch", lastSeen: .now.addingTimeInterval(-60 * 180), isCurrent: false, isTrusted: false)
|
||||
return [
|
||||
DevicePresentation(
|
||||
name: session.deviceName,
|
||||
systemImage: symbolName(for: session.deviceName),
|
||||
lastSeen: .now,
|
||||
isCurrent: true,
|
||||
isTrusted: true
|
||||
)
|
||||
]
|
||||
|
||||
let count = max((model.profile?.deviceCount ?? 1) - 1, 0)
|
||||
return [current] + Array(others.prefix(count))
|
||||
}
|
||||
|
||||
private var session: AuthSession? {
|
||||
@@ -274,10 +278,9 @@ struct DevicesView: View {
|
||||
|
||||
Section {
|
||||
VStack(spacing: 12) {
|
||||
Button("Pair another device") {
|
||||
isPairingCodePresented = true
|
||||
}
|
||||
.buttonStyle(PrimaryActionStyle())
|
||||
Text("Start new device pairing from your idp.global web session, then scan the fresh pairing QR in this app.")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
|
||||
Button("Sign out everywhere") {
|
||||
model.signOut()
|
||||
@@ -288,11 +291,6 @@ struct DevicesView: View {
|
||||
}
|
||||
}
|
||||
.navigationTitle("Devices")
|
||||
.sheet(isPresented: $isPairingCodePresented) {
|
||||
if let session {
|
||||
OneTimePasscodeSheet(session: session)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func symbolName(for deviceName: String) -> String {
|
||||
|
||||
Reference in New Issue
Block a user