From bb44d813fd13eda0a370b731ba39cb596c2ccd9b Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Tue, 7 Jun 2022 21:18:50 -0600 Subject: [PATCH] Return to transaction list after creating new transactions --- Twigs/DataStore.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Twigs/DataStore.swift b/Twigs/DataStore.swift index ee82255..f4e8900 100644 --- a/Twigs/DataStore.swift +++ b/Twigs/DataStore.swift @@ -354,7 +354,11 @@ class DataStore : ObservableObject { } else { savedTransaction = try await self.apiService.createRecurringTransaction(transaction) } - self.recurringTransaction = .success(savedTransaction) + if transaction.id != "" { + self.recurringTransaction = .success(savedTransaction) + } else { + self.recurringTransaction = .empty + } if case var .success(transactions) = self.recurringTransactions { transactions = transactions.filter(withoutId: savedTransaction.id) transactions.append(savedTransaction) @@ -429,7 +433,11 @@ class DataStore : ObservableObject { } else { savedTransaction = try await self.apiService.createTransaction(transaction) } - self.transaction = .success(savedTransaction) + if transaction.id != "" { + self.transaction = .success(savedTransaction) + } else { + self.transaction = .empty + } await getTransactions() } catch { self.transaction = .error(error, transaction)