diff --git a/Budget/DataStoreProvider.swift b/Budget/DataStoreProvider.swift index c098fbc..6642882 100644 --- a/Budget/DataStoreProvider.swift +++ b/Budget/DataStoreProvider.swift @@ -28,7 +28,7 @@ class DataStoreProvider { } func transactionDataStore(_ category: Category? = nil) -> TransactionDataStore { - return TransactionDataStore(transactionRepository) + return TransactionDataStore(transactionRepository, category: category) } func userDataStore() -> UserDataStore { diff --git a/Budget/Transaction/TransactionDataStore.swift b/Budget/Transaction/TransactionDataStore.swift index 068711f..a18e887 100644 --- a/Budget/Transaction/TransactionDataStore.swift +++ b/Budget/Transaction/TransactionDataStore.swift @@ -19,9 +19,9 @@ class TransactionDataStore: ObservableObject { func getTransactions(_ category: Category? = nil) { self.transactions = .failure(.loading) - var categoryIds: [Int]? = nil + var categoryIds: [Int] = [] if category != nil { - categoryIds?.append(category!.id!) + categoryIds.append(category!.id!) } _ = self.transactionRepository.getTransactions(categoryIds: categoryIds, from: Date(timeIntervalSince1970: 0)) .receive(on: DispatchQueue.main)