From 739d7d74e767b181974226179c5f1a4b56146e4a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 27 Dec 2015 08:32:15 -0800 Subject: QML UI: load from cache before trying to sync with the cloud server This is a simple way to deal with a "no network" situation. But this isn't ideal, yet, if there is a slow network as the dive list will be reset again once the sync from the cloud finishes. So there is some more thought needed to make this work "mostly as expected". Signed-off-by: Dirk Hohndel --- qt-mobile/qmlmanager.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index c0a2149b3..7a226a542 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -57,8 +57,27 @@ void QMLManager::finishSetup() 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, "")) { + !same_string(prefs.cloud_storage_password, "") && + getCloudURL(url) == 0) { + clear_dive_file_data(); + QByteArray fileNamePrt = QFile::encodeName(url); + prefs.git_local_only = true; + int error = parse_file(fileNamePrt.data()); + prefs.git_local_only = false; + if (error) { + appendTextToLog(QString("loading dives from cache failed %1").arg(error)); + } else { + int i; + struct dive *d; + process_dives(false, false); + DiveListModel::instance()->clear(); + for_each_dive(i, d) { + DiveListModel::instance()->addDive(d); + } + appendTextToLog(QString("%1 dives loaded from cache").arg(i)); + } appendTextToLog("have cloud credentials, trying to connect"); tryRetrieveDataFromBackend(); } else { -- cgit v1.2.3-70-g09d2