import CottonKit import SwiftUI /// `/device` — "This phone" or "This Mac" (Spec 10.4): this device's own /// record page in the device table, the one `/devices/[id]` draws for every /// other device, with what this device is doing folded into its row /// (`native Device facts`). Its id is the one `read.devices` names `thisDevice`. struct ThisDeviceRoute: View { @Environment(\.cottonCore) private var core @State private var id: String? @State private var unread = false var body: some View { Group { if let id { TablePageRoute(table: "device", id: id) .settingsKeptFlows(table: "device", record: id) } else if unread { PaperScreen(title: HostNoun.titleCase) { QuietState( title: ShellLines.line("boot", "device.unread_title", ["host": HostNoun.titleCase]), message: ShellLines.line("boot", "device.unread_body")) .settingsFormWidth() } } else { PaperScreen { EmptyView() } } } .task { guard id == nil, let core else { return } let answer = try? await core.callJSON(CottonMethod.readDevices) id = answer?.untrimmed("thisDevice") unread = id == nil } } }