From 61adf5387fa5e4eaf4bc47835a0571dd2fd7ed37 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Wed, 11 Feb 2026 17:49:19 +0100 Subject: [PATCH] Updated the "delete(_: at: from: )" function of the TaskListViewModel view model in the app target to use the Repository protocol instead. --- App/Sources/View Models/TaskListViewModel.swift | 12 ++++++------ App/Sources/Views/TaskListView.swift | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/App/Sources/View Models/TaskListViewModel.swift b/App/Sources/View Models/TaskListViewModel.swift index 3eec5fc..9782bdf 100644 --- a/App/Sources/View Models/TaskListViewModel.swift +++ b/App/Sources/View Models/TaskListViewModel.swift @@ -87,21 +87,21 @@ extension TaskListView { /// Deletes tasks at the specified indices. /// - /// This method removes tasks from the model context after a swipe-to-delete action. - /// The deletion is performed through SwiftData's model context, which handles + /// This method removes tasks from the repository after a swipe-to-delete action. + /// The deletion is performed through the repository, which handles /// persistence and triggers automatic UI updates. /// /// - Parameters: /// - tasks: The current array of tasks. /// - offsets: The index set of tasks to delete. - /// - modelContext: The SwiftData model context to perform the deletion. - func deleteTasks( + /// - repository: The repository to perform the deletion. + func delete( _ tasks: [Todo], at offsets: IndexSet, - from modelContext: ModelContext + from repository: Repository ) { for index in offsets { - modelContext.delete(tasks[index]) + repository.delete(tasks[index]) } } diff --git a/App/Sources/Views/TaskListView.swift b/App/Sources/Views/TaskListView.swift index 955ec32..dacf3e2 100644 --- a/App/Sources/Views/TaskListView.swift +++ b/App/Sources/Views/TaskListView.swift @@ -45,7 +45,7 @@ struct TaskListView: View { group: viewModel.group, showCompleted: viewModel.showCompleted ) { tasks, offsets in - viewModel.deleteTasks( + viewModel.delete( tasks, at: offsets, from: modelContext