stopAutoSync method
Stops automatic synchronization for one or all users.
Implementation
void stopAutoSync({String? userId}) {
if (userId != null) {
final timer = _autoSyncTimers.remove(userId);
timer?.cancel();
// If we are stopping a specific user's timer, also ensure it's not
// marked for resumption if the manager is paused.
if (_isSyncPaused) {
_pausedAutoSyncUserIds.remove(userId);
}
// Update the global next sync time after stopping this timer
_updateNextSyncTime();
// Only log if a timer was actually stopped
if (timer != null) {
_logger.info('Auto-sync stopped for user: $userId');
}
return;
}
_cancelAllAutoSyncTimers();
// An explicit `stopAutoSync()` while paused means the caller does not want
// these users' auto-sync restored on resume, so forget them.
if (_isSyncPaused) {
_pausedAutoSyncUserIds.clear();
}
}