Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurtanuki committed Oct 12, 2024
1 parent 1a0509e commit 4d6d1c1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/smooth_app/lib/background/background_task_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,8 @@ class BackgroundTaskManager {
/// `forceNowIfPossible = true`
/// 2. we're just checking casually if there are pending tasks
/// `forceNowIfPossible = false`
void run({final bool forceNowIfPossible = false}) {
final int? now = _canStartNow(forceNowIfPossible);
if (now == null) {
return;
}
// we need to put _running = true there in order to avoid async side-effects
_running = true;
unawaited(_runAsync(now));
}
void run({final bool forceNowIfPossible = false}) =>
unawaited(_runAsync(forceNowIfPossible));

/// Runs all the pending tasks, and then smoothly ends.
///
Expand All @@ -178,7 +171,13 @@ class BackgroundTaskManager {
/// If a task fails and another task with the same stamp comes after,
/// we can remove the failed task from the list: it would have been
/// overwritten anyway.
Future<void> _runAsync(final int now) async {
Future<void> _runAsync(final bool forceNowIfPossible) async {
final int? now = _canStartNow(forceNowIfPossible);
if (now == null) {
return;
}
_running = true;

/// Will also set the "latest start timestamp".
/// With this, we can detect a run that went wrong.
/// Like, still running 1 hour later.
Expand Down

0 comments on commit 4d6d1c1

Please sign in to comment.