mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: load from cache first when changing cloud credentials
We need to execute the same sequence of steps both when starting the app and when switching cloud credentials. This way things will work correctly when the device is offline and the user wants to switch accounts. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0cc9ad0619
commit
87f62dfaa8
2 changed files with 32 additions and 24 deletions
|
@ -58,17 +58,8 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
|||
syncLoadFromCloud();
|
||||
}
|
||||
|
||||
void QMLManager::finishSetup()
|
||||
void QMLManager::openLocalThenRemote(QString url)
|
||||
{
|
||||
// Initialize cloud credentials.
|
||||
setCloudUserName(prefs.cloud_storage_email);
|
||||
setCloudPassword(prefs.cloud_storage_password);
|
||||
setSaveCloudPassword(prefs.save_password_local);
|
||||
// if the cloud credentials are valid, we should get the GPS Webservice ID as well
|
||||
QString url;
|
||||
if (!same_string(prefs.cloud_storage_email, "") &&
|
||||
!same_string(prefs.cloud_storage_password, "") &&
|
||||
getCloudURL(url) == 0) {
|
||||
clear_dive_file_data();
|
||||
QByteArray fileNamePrt = QFile::encodeName(url);
|
||||
prefs.git_local_only = true;
|
||||
|
@ -92,6 +83,20 @@ void QMLManager::finishSetup()
|
|||
}
|
||||
appendTextToLog(QStringLiteral("have cloud credentials, trying to connect"));
|
||||
tryRetrieveDataFromBackend();
|
||||
}
|
||||
|
||||
void QMLManager::finishSetup()
|
||||
{
|
||||
// Initialize cloud credentials.
|
||||
setCloudUserName(prefs.cloud_storage_email);
|
||||
setCloudPassword(prefs.cloud_storage_password);
|
||||
setSaveCloudPassword(prefs.save_password_local);
|
||||
// if the cloud credentials are valid, we should get the GPS Webservice ID as well
|
||||
QString url;
|
||||
if (!same_string(prefs.cloud_storage_email, "") &&
|
||||
!same_string(prefs.cloud_storage_password, "") &&
|
||||
getCloudURL(url) == 0) {
|
||||
openLocalThenRemote(url);
|
||||
} else {
|
||||
appendTextToLog(QStringLiteral("no cloud credentials, tell user no dives found"));
|
||||
setStartPageText(tr("No recorded dives found. You can download your dives to this device from the Subsurface cloud storage service, from your dive computer, or add them manually."));
|
||||
|
@ -154,7 +159,9 @@ void QMLManager::saveCloudCredentials()
|
|||
free(prefs.userid);
|
||||
prefs.userid = NULL;
|
||||
syncLoadFromCloud();
|
||||
tryRetrieveDataFromBackend();
|
||||
QString url;
|
||||
getCloudURL(url);
|
||||
openLocalThenRemote(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public slots:
|
|||
void populateGpsData();
|
||||
void clearGpsData();
|
||||
void finishSetup();
|
||||
void openLocalThenRemote(QString url);
|
||||
void showMap(const QString& location);
|
||||
QString getNumber(const QString& diveId);
|
||||
QString getDate(const QString& diveId);
|
||||
|
|
Loading…
Add table
Reference in a new issue