Mobile: remember if we were able to open the local cache

If there is a local cache, we at least once successfully accessed the cloud, so
this is a valid cloud based git tree.

Without this change we run into a subtle bug: after a fresh install, or when
switching users, when the cloud data is accessed the very first time, we don't
remember that this was indeed loaded from the cloud. So if we then download
from a dive computer or make any other changes to the dive log, we cannot save
those dives to cloud storage - but we fail silently doing so. Which to the user
would look that inexplicable data loss.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-11-03 05:06:10 -08:00
parent 08e2013d1e
commit ccace53b83
2 changed files with 4 additions and 0 deletions

View file

@ -1,3 +1,4 @@
Mobile: fix subtle potential new data loss bug in first session connecting to a cloud account
Planner: Add checkbox on considering oxygen narcotic Planner: Add checkbox on considering oxygen narcotic
Planner: Improve rounding of stop durations in planner notes Planner: Improve rounding of stop durations in planner notes
Desktop: register changes when clicking "done" on dive-site edit screen Desktop: register changes when clicking "done" on dive-site edit screen

View file

@ -302,6 +302,9 @@ void QMLManager::openLocalThenRemote(QString url)
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_NEED_TO_VERIFY); QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_NEED_TO_VERIFY);
} else { } else {
// if we can load from the cache, we know that we have a valid cloud account // if we can load from the cache, we know that we have a valid cloud account
// and we know that there was at least one successful sync with the cloud when
// that local cache was created - so there is a common ancestor
setLoadFromCloud(true);
if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_UNKNOWN) if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_UNKNOWN)
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_VERIFIED); QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_VERIFIED);
if (git_prefs.unit_system == IMPERIAL) if (git_prefs.unit_system == IMPERIAL)