summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-06-18 18:14:05 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-06-20 11:13:13 +0900
commit7ec9c206b5cbf6b4ddbfc17aae9f683483a55ca7 (patch)
tree9648acd3d09ce90ec4994ca4a6158ac4d35cbf5f /mobile-widgets
parente6835d76cc56991619ca65af9f4187ffa6806aa9 (diff)
downloadsubsurface-7ec9c206b5cbf6b4ddbfc17aae9f683483a55ca7.tar.gz
QML UI: store nocloud data when adding cloud credentials
We want to allow people to keep dives they collected without a cloud account. The code was mostly there, we just got confused about the existing status because we ran through this twice (no cloud -> unknown -> verified). This way we explicitly remember this kind of transition. Fixes #1404 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 90cf97b2b..b27fe4b37 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -37,6 +37,7 @@
#include "core/ssrf.h"
QMLManager *QMLManager::m_instance = NULL;
+bool noCloudToCloud = false;
#define RED_FONT QLatin1Literal("<font color=\"red\">")
#define END_FONT QLatin1Literal("</font>")
@@ -442,6 +443,12 @@ void QMLManager::saveCloudCredentials()
free((void *)prefs.cloud_storage_password);
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
}
+ if (QMLPrefs::instance()->oldStatus() == QMLPrefs::CS_NOCLOUD && cloudCredentialsChanged && dive_table.nr) {
+ // we came from NOCLOUD and are connecting to a cloud account;
+ // since we already have dives in the table, let's remember that so we can keep them
+ noCloudToCloud = true;
+ appendTextToLog("transitioning from no-cloud to cloud and have dives");
+ }
if (QMLPrefs::instance()->cloudUserName().isEmpty() ||
QMLPrefs::instance()->cloudPassword().isEmpty()) {
setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
@@ -624,7 +631,13 @@ void QMLManager::loadDivesWithValidCredentials()
}
appendTextToLog("Cloud sync brought newer data, reloading the dive list");
- clear_dive_file_data();
+ // if we aren't switching from no-cloud mode, let's clear the dive data
+ if (!noCloudToCloud) {
+ appendTextToLog("Clear out in memory dive data");
+ clear_dive_file_data();
+ } else {
+ appendTextToLog("Switching from no cloud mode; keep in memory dive data");
+ }
if (git != dummy_git_repository) {
appendTextToLog(QString("have repository and branch %1").arg(branch));
error = git_load_dives(git, branch);
@@ -649,13 +662,14 @@ successful_exit:
setLoadFromCloud(true);
// if we came from local storage mode, let's merge the local data into the local cache
// for the remote data - which then later gets merged with the remote data if necessary
- if (QMLPrefs::instance()->oldStatus() == QMLPrefs::CS_NOCLOUD) {
+ if (noCloudToCloud) {
git_storage_update_progress(qPrintable(tr("Loading dives from local storage ('no cloud' mode)")));
dive_table.preexisting = dive_table.nr;
mergeLocalRepo();
DiveListModel::instance()->clear();
DiveListModel::instance()->addAllDives();
appendTextToLog(QStringLiteral("%1 dives loaded after importing nocloud local storage").arg(dive_table.nr));
+ noCloudToCloud = false;
saveChangesLocal();
if (m_syncToCloud == false) {
appendTextToLog(QStringLiteral("taking things back offline now that storage is synced"));