Simplify code - we now can rely on git_local_only to do the right thing

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-04-08 12:33:07 -07:00
parent eefda2b090
commit 685d31cd4f

View file

@ -754,19 +754,15 @@ void QMLManager::saveChangesLocal()
} }
alreadySaving = true; alreadySaving = true;
bool glo = prefs.git_local_only; bool glo = prefs.git_local_only;
bool cbs = prefs.cloud_background_sync;
prefs.git_local_only = true; prefs.git_local_only = true;
prefs.cloud_background_sync = false;
if (save_dives(existing_filename)) { if (save_dives(existing_filename)) {
appendTextToLog(get_error_string()); appendTextToLog(get_error_string());
setAccessingCloud(-1); setAccessingCloud(-1);
prefs.git_local_only = glo; prefs.git_local_only = glo;
prefs.cloud_background_sync = cbs;
alreadySaving = false; alreadySaving = false;
return; return;
} }
prefs.git_local_only = glo; prefs.git_local_only = glo;
prefs.cloud_background_sync = cbs;
mark_divelist_changed(false); mark_divelist_changed(false);
git_storage_update_progress(false, "done with local save"); git_storage_update_progress(false, "done with local save");
alreadySaving = false; alreadySaving = false;
@ -783,7 +779,6 @@ void QMLManager::saveChangesCloud()
return; return;
} }
bool glo = prefs.git_local_only; bool glo = prefs.git_local_only;
bool cbs = prefs.cloud_background_sync;
// first we need to store any unsaved changes to the local repo // first we need to store any unsaved changes to the local repo
saveChangesLocal(); saveChangesLocal();
if (alreadySaving) { if (alreadySaving) {
@ -797,7 +792,6 @@ void QMLManager::saveChangesCloud()
git_storage_update_progress(false, "finished syncing dive list to cloud server"); git_storage_update_progress(false, "finished syncing dive list to cloud server");
setAccessingCloud(-1); setAccessingCloud(-1);
prefs.git_local_only = glo; prefs.git_local_only = glo;
prefs.cloud_background_sync = cbs;
alreadySaving = false; alreadySaving = false;
} }
@ -1117,11 +1111,9 @@ void QMLManager::setSyncToCloud(bool status)
{ {
m_syncToCloud = status; m_syncToCloud = status;
prefs.git_local_only = !status; prefs.git_local_only = !status;
prefs.cloud_background_sync = status;
QSettings s; QSettings s;
s.beginGroup("CloudStorage"); s.beginGroup("CloudStorage");
s.setValue("git_local_only", prefs.git_local_only); s.setValue("git_local_only", prefs.git_local_only);
s.setValue("cloud_background_sync", prefs.cloud_background_sync);
emit syncToCloudChanged(); emit syncToCloudChanged();
} }