logic: Start automatic update checks on second day of use
* Added status messages for update check
This commit is contained in:
@@ -415,6 +415,14 @@ void Application::loadWindow(bool showStartWindow)
|
||||
if (!m_loadedWindow)
|
||||
{
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
|
||||
// delay first update check by 24 hours at first launch
|
||||
if (!appSettings->getLastUpdateCheck().isValid())
|
||||
{
|
||||
appSettings->setLastUpdateCheck(TimeStamp::now());
|
||||
appSettings->save();
|
||||
}
|
||||
|
||||
LicenseChecker::LicenseState state = LicenseChecker::LicenseState::VALID;
|
||||
std::string licenseError;
|
||||
|
||||
|
||||
@@ -546,13 +546,7 @@ void ApplicationSettings::setAutomaticUpdateCheck(bool automaticUpdates)
|
||||
|
||||
TimeStamp ApplicationSettings::getLastUpdateCheck() const
|
||||
{
|
||||
std::string val = getValue<std::string>("user/update_check/time_stamp", "");
|
||||
if (!val.size())
|
||||
{
|
||||
val = getValue<std::string>("user/update_check/last", ""); // deprecated key
|
||||
}
|
||||
|
||||
return TimeStamp(val);
|
||||
return TimeStamp(getValue<std::string>("user/update_check/time_stamp", ""));
|
||||
}
|
||||
|
||||
void ApplicationSettings::setLastUpdateCheck(const TimeStamp& time)
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
#include <QJsonObject>
|
||||
#include <QUrl>
|
||||
|
||||
#include "LicenseChecker.h"
|
||||
#include "QtRequest.h"
|
||||
#include "ApplicationSettings.h"
|
||||
#include "Version.h"
|
||||
#include "LicenseChecker.h"
|
||||
#include "MessageStatus.h"
|
||||
#include "QtRequest.h"
|
||||
#include "utility.h"
|
||||
#include "utilityApp.h"
|
||||
#include "utilityUuid.h"
|
||||
#include "Version.h"
|
||||
|
||||
bool QtUpdateChecker::needsAutomaticCheck()
|
||||
{
|
||||
@@ -107,6 +108,8 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
|
||||
if (updateVersion > Version::getApplicationVersion())
|
||||
{
|
||||
MessageStatus(L"Newest available version: " + updateVersion.toDisplayWString()).dispatch();
|
||||
|
||||
result.version = updateVersion;
|
||||
result.url = url;
|
||||
|
||||
@@ -139,6 +142,10 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageStatus(L"Sourcetrail is up-to-date").dispatch();
|
||||
}
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -147,6 +154,11 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
appSettings->save();
|
||||
}
|
||||
|
||||
if (!result.success)
|
||||
{
|
||||
MessageStatus(L"Update check failed", true).dispatch();
|
||||
}
|
||||
|
||||
request->deleteLater();
|
||||
|
||||
callback(result);
|
||||
@@ -154,6 +166,7 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
);
|
||||
|
||||
request->sendRequest(urlString);
|
||||
MessageStatus(L"Checking for new version", false, true).dispatch();
|
||||
}
|
||||
|
||||
void QtUpdateChecker::checkUpdate()
|
||||
|
||||
Reference in New Issue
Block a user