Fix "Check for updates" not working due to time cooldown (#6232)

* Fix "Check for updates" not working due to time cooldown

* Update AppUpdateChecker.kt

Co-authored-by: arkon <arkon@users.noreply.github.com>
(cherry picked from commit c0d0ff66b6b73efae29635a61e4ee2ea13a925b3)
This commit is contained in:
Andreas 2021-11-14 16:23:12 +01:00 committed by Jobobby04
parent 4ea72f5342
commit bc73e9f1d8
2 changed files with 3 additions and 3 deletions

View File

@ -18,9 +18,9 @@ class AppUpdateChecker {
private val networkService: NetworkHelper by injectLazy()
private val preferences: PreferencesHelper by injectLazy()
suspend fun checkForUpdate(context: Context): AppUpdateResult {
suspend fun checkForUpdate(context: Context, isUserPrompt: Boolean = false): AppUpdateResult {
// Limit checks to once a day at most
if (Date().time < preferences.lastAppCheck().get() + TimeUnit.DAYS.toMillis(1)) {
if (isUserPrompt.not() && Date().time < preferences.lastAppCheck().get() + TimeUnit.DAYS.toMillis(1)) {
return AppUpdateResult.NoNewUpdate
}

View File

@ -102,7 +102,7 @@ class AboutController : SettingsController(), NoAppBarElevationController {
launchNow {
try {
when (val result = updateChecker.checkForUpdate(activity!!)) {
when (val result = updateChecker.checkForUpdate(activity!!, isUserPrompt = true)) {
is AppUpdateResult.NewUpdate -> {
NewUpdateDialogController(result).showDialog(router)
}