Implemented the view refresh after data updates for the TaskGroupListView view in the app target.
This commit is contained in:
@@ -12,11 +12,12 @@ struct TaskGroupListView: View {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The SwiftData model context for database operations.
|
||||
/// Query to monitor all todo tasks for changes.
|
||||
///
|
||||
/// This context is used by the view model to perform efficient database-level queries for counting tasks in each group.
|
||||
@Environment(\.modelContext)
|
||||
private var modelContext
|
||||
/// This query triggers view updates whenever todo tasks are inserted, updated, or deleted,
|
||||
/// ensuring the task counts displayed in the view remain accurate.
|
||||
@Query
|
||||
private var tasks: [Todo]
|
||||
|
||||
/// The view model managing the state and logic for this view.
|
||||
///
|
||||
@@ -43,10 +44,7 @@ struct TaskGroupListView: View {
|
||||
NavigationLink(destination: TaskListView(group: group)) {
|
||||
Card(
|
||||
group: group,
|
||||
count: viewModel.count(
|
||||
for: group,
|
||||
in: modelContext
|
||||
)
|
||||
count: viewModel.count(tasks, for: group)
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
Reference in New Issue
Block a user