Fix some async loading issues
This commit is contained in:
parent
ec425642b4
commit
4b5a6c6558
5 changed files with 18 additions and 13 deletions
|
@ -75,12 +75,6 @@ struct SidebarBudgetView: View {
|
|||
}
|
||||
}
|
||||
})
|
||||
.sheet(isPresented: $budgetDataStore.showBudgetSelection,
|
||||
content: {
|
||||
List {
|
||||
BudgetListsView().environmentObject(budgetDataStore)
|
||||
}
|
||||
})
|
||||
.interactiveDismissDisabled(true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import TwigsCore
|
|||
struct TabbedBudgetView: View {
|
||||
@EnvironmentObject var authenticationDataStore: AuthenticationDataStore
|
||||
@EnvironmentObject var budgetDataStore: BudgetsDataStore
|
||||
@EnvironmentObject var apiService: TwigsInMemoryCacheService
|
||||
@EnvironmentObject var apiService: TwigsApiService
|
||||
@State var tabSelection: Int = 0
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
@ -11,6 +11,7 @@ import Combine
|
|||
import Collections
|
||||
import TwigsCore
|
||||
|
||||
@MainActor
|
||||
class TransactionDataStore: ObservableObject {
|
||||
@Published var transactions: AsyncData<OrderedDictionary<String, [Transaction]>> = .empty
|
||||
@Published var transaction: AsyncData<Transaction> = .empty {
|
||||
|
|
|
@ -56,7 +56,7 @@ struct TransactionFormSheet: View {
|
|||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
}.environmentObject(transactionForm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,21 @@ import TwigsCore
|
|||
|
||||
struct MainView: View {
|
||||
@StateObject var authenticationDataStore: AuthenticationDataStore
|
||||
@StateObject var budgetDataStore: BudgetsDataStore
|
||||
@StateObject var transactionList: TransactionDataStore
|
||||
@StateObject var categoryList: CategoryListDataStore
|
||||
@StateObject var userDataStore: UserDataStore
|
||||
@StateObject var recurringTransactionList: RecurringTransactionDataStore
|
||||
let apiService: TwigsApiService
|
||||
|
||||
init(_ apiService: TwigsApiService, baseUrl: Binding<String>, token: Binding<String>, userId: Binding<String>) {
|
||||
self.apiService = apiService
|
||||
self._authenticationDataStore = StateObject(wrappedValue: AuthenticationDataStore(apiService, baseUrl: baseUrl, token: token, userId: userId))
|
||||
self._budgetDataStore = StateObject(wrappedValue: BudgetsDataStore(budgetRepository: apiService, categoryRepository: apiService, transactionRepository: apiService))
|
||||
self._categoryList = StateObject(wrappedValue: CategoryListDataStore(apiService))
|
||||
self._userDataStore = StateObject(wrappedValue: UserDataStore(apiService))
|
||||
self._transactionList = StateObject(wrappedValue: TransactionDataStore(apiService))
|
||||
self._recurringTransactionList = StateObject(wrappedValue: RecurringTransactionDataStore(apiService))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
@ -29,11 +39,11 @@ struct MainView: View {
|
|||
|
||||
var body: some View {
|
||||
mainView
|
||||
.environmentObject(TransactionDataStore(apiService))
|
||||
.environmentObject(CategoryListDataStore(apiService))
|
||||
.environmentObject(BudgetsDataStore(budgetRepository: apiService, categoryRepository: apiService, transactionRepository: apiService))
|
||||
.environmentObject(UserDataStore(apiService))
|
||||
.environmentObject(RecurringTransactionDataStore(apiService))
|
||||
.environmentObject(transactionList)
|
||||
.environmentObject(categoryList)
|
||||
.environmentObject(budgetDataStore)
|
||||
.environmentObject(userDataStore)
|
||||
.environmentObject(recurringTransactionList)
|
||||
.environmentObject(authenticationDataStore)
|
||||
.onAppear {
|
||||
Task {
|
||||
|
|
Loading…
Reference in a new issue