diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-02-05 00:23:05 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-02-05 00:23:05 +0100 |
| commit | 91fd86189477e6c690c6487d51d80bc58c8ecb63 (patch) | |
| tree | 3817b2572037deab029cd0c1b99d936ee1abcf45 /Map/State | |
| parent | 144167621e845b05df55a9f2f00c4bc270d42b55 (diff) | |
Make delete a context action
Diffstat (limited to 'Map/State')
| -rw-r--r-- | Map/State/AppState.swift | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Map/State/AppState.swift b/Map/State/AppState.swift index cbc9ba6..f062051 100644 --- a/Map/State/AppState.swift +++ b/Map/State/AppState.swift @@ -4,13 +4,13 @@ import SwiftUI struct AppState { var selectedEvolution: StageType = .general - var mapBeingDeleted: Map? = nil } enum AppAction { case selectEvolution(evolution: StageType) case exportMapAsImage(map: Map) case exportMapAsText(map: Map) + case deleteMap(map: Map) } func appStateReducer(state: inout AppState, action: AppAction) { @@ -91,6 +91,11 @@ func appStateReducer(state: inout AppState, action: AppAction) { print("Cancel") } } + case .deleteMap(map: let map): + let context = PersistenceController.shared.container.viewContext + context.delete(map) + + try? context.save() } } |