Implemented the view refresh after data updates for the TaskGroupListView view in the app target.

This commit is contained in:
2026-02-10 03:18:56 +01:00
parent 52a54184af
commit 937941f50b
3 changed files with 45 additions and 55 deletions
+6 -8
View File
@@ -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)