summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-05 21:27:05 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-05 21:32:28 -0700
commitc3ab4dfc3e59515fd36cfa99c61f2b431f0480ea (patch)
treef81bfae26d01bc5021e95c80e817ebc188b0719c /mobile-widgets/qmlmanager.cpp
parenta1332ce36148e097fe7a9d7764bc02152d3b8425 (diff)
downloadsubsurface-c3ab4dfc3e59515fd36cfa99c61f2b431f0480ea.tar.gz
QML UI: simplify code for loading data from the cloud
We had a redundant check of the server reply hidden in there, and the logic which values were set where didn't really make much sense. This seems clearer to me. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index fa8a782c6..bf9459b0f 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -301,6 +301,7 @@ void QMLManager::retrieveUserid()
{
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
appendTextToLog(QStringLiteral("Cloud storage connection not working correctly: %1").arg(QString(reply->readAll())));
+ setStartPageText(RED_FONT + tr("Cannot connect to cloud storage") + END_FONT);
setAccessingCloud(-1);
return;
}
@@ -323,6 +324,9 @@ void QMLManager::retrieveUserid()
s.setValue("subsurface_webservice_uid", prefs.userid);
s.sync();
}
+ setCredentialStatus(VALID);
+ setStartPageText("Cloud credentials valid, loading dives...");
+ git_storage_update_progress(0, "load dives with valid credentials");
loadDivesWithValidCredentials();
}
@@ -339,16 +343,6 @@ void QMLManager::loadDiveProgress(int percent)
void QMLManager::loadDivesWithValidCredentials()
{
- if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
- appendTextToLog(QStringLiteral("Cloud storage connection not working correctly: ") + reply->readAll());
- setStartPageText(RED_FONT + tr("Cannot connect to cloud storage") + END_FONT);
- setAccessingCloud(-1);
- return;
- }
- setCredentialStatus(VALID);
- appendTextToLog("Cloud credentials valid, loading dives...");
- setStartPageText("Cloud credentials valid, loading dives...");
- git_storage_update_progress(0, "load dives with valid credentials");
QString url;
if (getCloudURL(url)) {
QString errorString(get_error_string());
@@ -368,6 +362,8 @@ void QMLManager::loadDivesWithValidCredentials()
clear_dive_file_data();
DiveListModel::instance()->clear();
+ appendTextToLog("Cloud sync brought newer data, reloading the dive list");
+
int error = parse_file(fileNamePrt.data());
setAccessingCloud(-1);
if (!error) {