fix: limit schedule timer tolerance to 10 min

This commit is contained in:
relikd
2026-01-11 19:30:45 +01:00
parent 1de44071aa
commit 6a5ca09754

View File

@@ -113,10 +113,14 @@ static _Atomic(NSUInteger) _queueSize = 0;
}); });
if (!nextTime) if (!nextTime)
nextTime = [NSDate distantFuture]; nextTime = [NSDate distantFuture];
NSTimeInterval tolerance = [nextTime timeIntervalSinceNow] * 0.15; int tolerance = (int)([nextTime timeIntervalSinceNow] * 0.15);
_timer.tolerance = (tolerance < 1 ? 1 : tolerance); // at least 1 sec tolerance = (tolerance < 1 ? 1 : tolerance > 600 ? 600 : tolerance); // at least 1 sec, upto 10 min
_timer.tolerance = tolerance;
_timer.fireDate = nextTime; _timer.fireDate = nextTime;
PostNotification(kNotificationScheduleTimerChanged, nil); PostNotification(kNotificationScheduleTimerChanged, nil);
#ifdef DEBUG
NSLog(@"schedule timer: %@ (+/- %d sec)", nextTime, tolerance);
#endif
} }
/// Called when schedule timer runs out (earliest @c .schedule date). Or if forced by user. /// Called when schedule timer runs out (earliest @c .schedule date). Or if forced by user.