summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-15 04:58:09 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-15 13:22:16 -0700
commit00ac1c12db347d7a63c4c44a62f41b373cb84706 (patch)
tree7accda4f901724992646bfbe4f5a5047c7fe4cb0 /mobile-widgets/qmlmanager.cpp
parent6985c123d412d3223618247e2fcc733cd99bb842 (diff)
downloadsubsurface-00ac1c12db347d7a63c4c44a62f41b373cb84706.tar.gz
QML UI: fix the save to cloud logic
There were several logical flaws here. Ugh. Don't save things if there are no unsaved changes, if we haven't initialized this repository from the cloud or if we are already saving things. Then, once we decide that we should save, first always save to the local cache and then check if we should save to the cloud and do so if requested. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 4fa32bdd9..95db4ad41 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -794,21 +794,27 @@ void QMLManager::saveChangesLocal()
void QMLManager::saveChangesCloud(bool forceRemoteSync)
{
- if (prefs.git_local_only && !forceRemoteSync)
+ if (!unsaved_changes()) {
+ appendTextToLog("asked to save changes but no unsaved changes");
return;
-
- git_storage_update_progress(true, "start save change to cloud");
+ }
if (!loadFromCloud()) {
appendTextToLog("Don't save dives without loading from the cloud, first.");
return;
}
- bool glo = prefs.git_local_only;
- // first we need to store any unsaved changes to the local repo
- saveChangesLocal();
if (alreadySaving) {
- appendTextToLog("save operation in progress already, can't sync with server");
+ appendTextToLog("save operation in progress already");
return;
}
+ // first we need to store any unsaved changes to the local repo
+ saveChangesLocal();
+
+ // if the user asked not to push to the cloud we are done
+ if (prefs.git_local_only && !forceRemoteSync)
+ return;
+
+ bool glo = prefs.git_local_only;
+ git_storage_update_progress(false, "start save change to cloud");
prefs.git_local_only = false;
alreadySaving = true;
loadDivesWithValidCredentials();
@@ -816,7 +822,6 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync)
git_storage_update_progress(false, "finished syncing dive list to cloud server");
setAccessingCloud(-1);
prefs.git_local_only = glo;
- alreadySaving = false;
}
bool QMLManager::undoDelete(int id)