Pasting events
This commit is contained in:
parent
197f93037a
commit
9257a4731c
@ -51,7 +51,7 @@ struct EventsScreen: View {
|
|||||||
presenting: viewModel.pastedEvent) { event in
|
presenting: viewModel.pastedEvent) { event in
|
||||||
Button("Cancel", role: .cancel, action: {})
|
Button("Cancel", role: .cancel, action: {})
|
||||||
Button("OK") {
|
Button("OK") {
|
||||||
viewModel.pasteEvent(event)
|
Task { await viewModel.addEvent(event) }
|
||||||
}
|
}
|
||||||
.keyboardShortcut(.defaultAction)
|
.keyboardShortcut(.defaultAction)
|
||||||
} message: { event in
|
} message: { event in
|
||||||
|
|||||||
@ -69,19 +69,21 @@ class EventsViewModel: ACHudContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addEvent(_ event: VehicleEventDto) async {
|
||||||
|
|
||||||
|
await eventOperation {
|
||||||
|
try await self.storageService.add(event: event, to: self.vehicle.getNumber())
|
||||||
|
} apiOperation: {
|
||||||
|
try await self.apiService.add(event: event, to: self.vehicle.getNumber())
|
||||||
|
}
|
||||||
|
|
||||||
|
updateEvents()
|
||||||
|
}
|
||||||
|
|
||||||
func addNewEvent() async {
|
func addNewEvent() async {
|
||||||
|
|
||||||
let newEvent = VehicleEventDto(lat: 0, lon: 0, addedBy: settingsService.user.email)
|
let newEvent = VehicleEventDto(lat: 0, lon: 0, addedBy: settingsService.user.email)
|
||||||
|
await addEvent(newEvent)
|
||||||
if let event = await coordinator?.editEvent(event: newEvent) {
|
|
||||||
await eventOperation {
|
|
||||||
try await self.storageService.add(event: event, to: self.vehicle.getNumber())
|
|
||||||
} apiOperation: {
|
|
||||||
try await self.apiService.add(event: event, to: self.vehicle.getNumber())
|
|
||||||
}
|
|
||||||
|
|
||||||
updateEvents()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteEvent(_ event: EventModel) async {
|
func deleteEvent(_ event: EventModel) async {
|
||||||
@ -172,8 +174,4 @@ class EventsViewModel: ACHudContainer {
|
|||||||
|
|
||||||
return date + "\n" + location
|
return date + "\n" + location
|
||||||
}
|
}
|
||||||
|
|
||||||
func pasteEvent(_ event: VehicleEventDto) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user