aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-02-23 21:43:52 -0600
committerIván Ávalos <avalos@disroot.org>2022-02-23 21:43:52 -0600
commit18b9ba25a6342d958d99ff005ea08a5b085b2ce8 (patch)
tree164931d5ccc413ebdc15f75c21c5538091b57e71
parentdfd9ba657b93a6f5b98246f6d174e02cc4132d46 (diff)
downloadetbsa-trackermap-mobile-18b9ba25a6342d958d99ff005ea08a5b085b2ce8.tar.gz
etbsa-trackermap-mobile-18b9ba25a6342d958d99ff005ea08a5b085b2ce8.tar.bz2
etbsa-trackermap-mobile-18b9ba25a6342d958d99ff005ea08a5b085b2ce8.zip
Fixed commands not working.
-rw-r--r--iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift12
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)
+ }
+ }
}
}
}