From 85bd3f6a38ab6020fc413fdff32643288d168415 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Wed, 11 Feb 2026 17:47:40 +0100 Subject: [PATCH] Updated the "save(to: )" function of the NewTaskViewModel view model in the app target to use the Repository protocol instead. --- App/Sources/View Models/NewTaskViewModel.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/App/Sources/View Models/NewTaskViewModel.swift b/App/Sources/View Models/NewTaskViewModel.swift index 732c753..9b3fbef 100644 --- a/App/Sources/View Models/NewTaskViewModel.swift +++ b/App/Sources/View Models/NewTaskViewModel.swift @@ -57,14 +57,14 @@ extension NewTaskView { // MARK: Functions - /// Saves a new todo task to the SwiftData model context. + /// Saves a new todo task to the repository. /// - /// This function creates a new `Todo` instance with the current property values and inserts it into the provided model context. + /// This function creates a new `Todo` instance with the current property values and inserts it into the provided repository. /// The title and note are trimmed of leading and trailing whitespace before saving. /// The `note` property value is only included if it's not empty after trimming. /// - /// - Parameter modelContext: The SwiftData model context to insert a new todo task. - func save(to modelContext: ModelContext) { + /// - Parameter repository: The repository to insert a new todo task. + func save(to repository: Repository) { let trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedNote = note.trimmingCharacters(in: .whitespacesAndNewlines) @@ -74,7 +74,7 @@ extension NewTaskView { due: due ) - modelContext.insert(todo) + repository.insert(todo) } }