Simpler api endpoints are now integrated into the MainViewModel

This commit is contained in:
Vicnet
2023-11-16 17:53:30 +01:00
parent 3563c23e29
commit 23e1a665df
13 changed files with 284 additions and 74 deletions

View File

@@ -9,8 +9,8 @@ import SwiftUI
struct MainView: View {
@ObservedObject var viewModel: MainViewModel
@ObservedObject var userSettings: UserSettings
@StateObject var viewModel = MainViewModel()
@State private var selectedCategory: Category? = nil
@State private var showEditView: Bool = false
@@ -90,7 +90,7 @@ struct MainView: View {
}
.task {
self.serverConnection = await viewModel.checkServerConnection()
await viewModel.loadCategoryList()
await viewModel.loadCategories()//viewModel.loadCategoryList()
// Open detail view for default category
if userSettings.defaultCategory != "" {
if let cat = viewModel.categories.first(where: { c in
@@ -105,7 +105,7 @@ struct MainView: View {
}
.refreshable {
self.serverConnection = await viewModel.checkServerConnection()
await viewModel.loadCategoryList(needsUpdate: true)
await viewModel.loadCategories()//loadCategoryList(needsUpdate: true)
}
}
@@ -208,7 +208,7 @@ struct RecipeSearchView: View {
.navigationTitle("Search recipe")
}
.task {
allRecipes = await viewModel.getAllRecipes()
allRecipes = await viewModel.getRecipes()//.getAllRecipes()
}
}