Jul 27 - Update code for scheduled tasks 3
This commit is contained in:
@@ -770,6 +770,7 @@ struct ExecuteInspectionView: View {
|
||||
$0.templateServerId == tid &&
|
||||
$0.facilityServerId == fid &&
|
||||
($0.inspectorId == nil || $0.inspectorId == uid) &&
|
||||
!$0.fulfilledLocally && // already satisfied, awaiting sync
|
||||
!$0.dueDateString.isEmpty &&
|
||||
$0.dueDateString <= today // ISO strings sort chronologically
|
||||
}
|
||||
@@ -781,12 +782,21 @@ struct ExecuteInspectionView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the cached row for whichever schedule this submission fulfils.
|
||||
// Hide the row until the server confirms what happened to it.
|
||||
//
|
||||
// NOT a delete. A recurring schedule comes back from the server on its
|
||||
// next occurrence, so deleting turned every completion into a
|
||||
// delete-then-reinsert against the `@Attribute(.unique)` serverId, and
|
||||
// the reinserted row did not reliably pick up the new due date — a
|
||||
// daily schedule kept showing today's date after being completed.
|
||||
// One-time schedules masked it, because the server stops returning them
|
||||
// and they are never reinserted. Flagging leaves `update(from:)` as the
|
||||
// single path that ever writes a cached schedule's dates.
|
||||
guard let schedId = inspection.scheduledInspectionServerId,
|
||||
let sched = all.first(where: { $0.serverId == schedId })
|
||||
else { return }
|
||||
|
||||
context.delete(sched)
|
||||
sched.fulfilledLocally = true
|
||||
}
|
||||
|
||||
/// "yyyy-MM-dd", matching `LocalScheduledInspection.dueDateString`.
|
||||
|
||||
Reference in New Issue
Block a user