From e27de144fe1f8312979b19ec38f144e1f4c6903d Mon Sep 17 00:00:00 2001 From: William Brawner Date: Thu, 21 Oct 2021 20:47:52 -0600 Subject: [PATCH] Fix inability to edit multiple categories --- Twigs/Category/CategoryDataStore.swift | 4 ++++ Twigs/Category/CategoryFormSheet.swift | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Twigs/Category/CategoryDataStore.swift b/Twigs/Category/CategoryDataStore.swift index 4631cec..d99b301 100644 --- a/Twigs/Category/CategoryDataStore.swift +++ b/Twigs/Category/CategoryDataStore.swift @@ -100,6 +100,10 @@ class CategoryDataStore: ObservableObject { }) } + func clearSelectedCategory() { + self.category = .failure(.unknown) + } + private let categoryRepository: CategoryRepository init(_ categoryRepository: CategoryRepository) { self.categoryRepository = categoryRepository diff --git a/Twigs/Category/CategoryFormSheet.swift b/Twigs/Category/CategoryFormSheet.swift index 173f099..8dc5d77 100644 --- a/Twigs/Category/CategoryFormSheet.swift +++ b/Twigs/Category/CategoryFormSheet.swift @@ -78,6 +78,8 @@ struct CategoryFormSheet: View { archived: false )) }) + }.onDisappear { + self.categoryDataStore.clearSelectedCategory() } }