Android: the release check at each start of the app, not once a day
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

The owner did not hear of 1.8.0 a day after 1.7.0: the phone asked only 24 h after its
last answer, restarts included. Now each start asks, as the desktop does; a return to
the app asks 6 h after the last answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-27 12:15:09 +03:00
parent 8e79a888ef
commit b5227dd998
3 changed files with 16 additions and 8 deletions

View file

@ -198,11 +198,17 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope
}
}
/// On start and on return to the app: a check when one is due (§25.6).
/// Whether this run of the app asked already: the first start always asks.
private var askedThisRun = false
/// On start and on return to the app: a check when one is due (§25.6): at each start
/// of the app, as the desktop does (a release out since the last check is offered at
/// once), and on return 6 h after the last answer (1 h after a failed try).
fun checkIfDue() {
if (!_auto.value || busy()) return
val now = System.currentTimeMillis()
if (now - _lastCheck.value < DAY || now - prefs.getLong(LAST_ATTEMPT, 0L) < HOUR) return
if (askedThisRun && (now - _lastCheck.value < RECHECK || now - prefs.getLong(LAST_ATTEMPT, 0L) < HOUR)) return
askedThisRun = true
scope.launch { runCheck(manual = false) }
}
@ -613,7 +619,7 @@ class AppUpdates(private val context: Context, private val scope: CoroutineScope
const val UPDATED_FROM = "updatedFrom"
/// No longer used (until 1.0.1).
const val UPDATED_PAGE = "updatedPage"
const val DAY = 24 * 60 * 60 * 1000L
const val RECHECK = 6 * 60 * 60 * 1000L
const val HOUR = 60 * 60 * 1000L
}
}