|
|
@@ -78,6 +78,7 @@ struct ContentView: View {
|
|
|
let ymd = weekStart.formatted(.iso8601.year().month().day())
|
|
|
save(to: URL.documentsDirectory.appending(path: "Todo \(ymd).yaml"))
|
|
|
weekStart = now
|
|
|
+ cleanup()
|
|
|
}
|
|
|
|
|
|
private func save(to: URL) {
|
|
|
@@ -91,6 +92,24 @@ struct ContentView: View {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private func cleanup() {
|
|
|
+ for item in items {
|
|
|
+ item.tasks.removeAll(where: { $0.status == .Complete })
|
|
|
+ for task in item.tasks {
|
|
|
+ if task.status == .InProgress {
|
|
|
+ task.status = .Todo
|
|
|
+ }
|
|
|
+
|
|
|
+ task.subtasks.removeAll(where: { $0.status == .Complete })
|
|
|
+ for subtask in task.subtasks {
|
|
|
+ if subtask.status == .InProgress {
|
|
|
+ subtask.status = .Todo
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private func deleteItem(item: Category) {
|
|
|
withAnimation {
|
|
|
modelContext.delete(item)
|