diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-02-25 22:02:51 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-02-25 22:02:51 -0600 |
commit | 136e4ebe289e286b62c8e37bcd512de6df0de0d3 (patch) | |
tree | 894ce7d172a39b0a7c99e19e9b4d25064549529a /iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift | |
parent | ef7a88961841752cb1a38a39f5e0cc298b463f56 (diff) | |
parent | 70141fe10227ef4eca2ef7ae4b2b9d7c8fac5675 (diff) | |
download | etbsa-trackermap-mobile-136e4ebe289e286b62c8e37bcd512de6df0de0d3.tar.gz etbsa-trackermap-mobile-136e4ebe289e286b62c8e37bcd512de6df0de0d3.tar.bz2 etbsa-trackermap-mobile-136e4ebe289e286b62c8e37bcd512de6df0de0d3.zip |
Merge branch 'main' into ios_reports
Diffstat (limited to 'iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift')
-rw-r--r-- | iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift b/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift index d7298c4..8e1da00 100644 --- a/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift +++ b/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift @@ -21,6 +21,7 @@ import shared class UnitCommandsViewModel: ObservableObject { @Inject var commandsController: CommandsController + var deviceId: Int32? = nil @Published var commands = [Command]() @Published var selected: Command? @Published var selectedId: Int = 0 { @@ -29,6 +30,9 @@ class UnitCommandsViewModel: ObservableObject { Int(truncating: $0.id!) == selectedId }) { self.selected = selected + if let id = deviceId { + self.selected?.deviceId = KotlinInt(int: id) + } notSelected = false } else { self.selected = nil @@ -40,6 +44,7 @@ class UnitCommandsViewModel: ObservableObject { @Published var showConfirmation: Bool = false func fetchCommands(id: Int32) { + deviceId = id commandsController.fetchCommands(deviceId: id) { commands, error in print("We've got the commands! \(commands ?? [])") self.commands = commands ?? [] @@ -48,7 +53,12 @@ class UnitCommandsViewModel: ObservableObject { func sendCommand() { if let command = selected { - commandsController.sendCommand(command: command) { _, error in } + commandsController.sendCommand(command: command) { _, error in + if let error = error { + print("There is a fucking error") + print(error.localizedDescription) + } + } } } } |