desktop/update-check: fix logic when to ask about update check

Checking a field that we intentionally don't store to disk is obviously
wrong. It's been this way for a long time and it has annoyed me many
times, but somehow I never spent the time to track down why this was
happening.

It makes much more sense to use the presence of either the don't check
flag or a next check date as an indication that we have already asked
this question.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2021-01-05 12:07:41 -08:00
parent fabeb71ade
commit d63910caa3

View file

@ -22,7 +22,6 @@ UpdateManager::UpdateManager(QObject *parent) :
return; return;
qPrefUpdateManager::set_last_version_used(subsurface_git_version()); qPrefUpdateManager::set_last_version_used(subsurface_git_version());
qPrefUpdateManager::set_next_check(QDate::currentDate().addDays(14));
checkForUpdates(true); checkForUpdates(true);
} }
@ -107,8 +106,7 @@ void UpdateManager::requestReceived()
} }
if (isAutomaticCheck) { if (isAutomaticCheck) {
auto update_settings = qPrefUpdateManager::instance(); auto update_settings = qPrefUpdateManager::instance();
if (!update_settings->dont_check_exists()) { if (!update_settings->dont_check_for_updates() && update_settings->next_check() == QDate::fromJulianDay(0)) {
// we allow an opt out of future checks // we allow an opt out of future checks
QMessageBox response(MainWindow::instance()); QMessageBox response(MainWindow::instance());
QString message = tr("Subsurface is checking every two weeks if a new version is available. " QString message = tr("Subsurface is checking every two weeks if a new version is available. "
@ -120,7 +118,7 @@ void UpdateManager::requestReceived()
response.setIcon(QMessageBox::Question); response.setIcon(QMessageBox::Question);
response.setWindowModality(Qt::WindowModal); response.setWindowModality(Qt::WindowModal);
update_settings->set_dont_check_for_updates(response.exec() != QMessageBox::Accepted); update_settings->set_dont_check_for_updates(response.exec() != QMessageBox::Accepted);
update_settings->set_dont_check_exists(true);
} }
} }
qPrefUpdateManager::set_next_check(QDate::currentDate().addDays(14));
} }