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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-12-27 08:32:15 -08:00
parent 83bd46cf79
commit 739d7d74e7

View file

@ -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 {