mobile: pull undo/redo notification text up

When changes need saving, the notification text was set quite
deep in the calltree in "saveChangesLocal()". I don't know why
this was put so deep in the call tree. In any case, it prevents
asynchronous saving of the data. Therefore, pull it up to
chnagesNeedSaving().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-30 21:39:08 +01:00 committed by bstoeger
parent dd466d2d48
commit 2172e18298
2 changed files with 17 additions and 16 deletions

View file

@ -1452,11 +1452,21 @@ void QMLManager::changesNeedSaving(bool fromUndo)
mark_divelist_changed(true);
emit syncStateChanged();
#if defined(Q_OS_IOS)
saveChangesLocal(fromUndo);
saveChangesLocal();
#else
saveChangesCloud(false, fromUndo);
saveChangesCloud(false);
#endif
updateAllGlobalLists();
// provide a useful undo/redo notification
// NOTE: the QML UI interprets a leading '[action]' (where only the two brackets are checked for)
// as an indication to use the text between those two brackets as the label of a button that
// can be used to open the context menu
QString msgFormat = tr("[%1]Changes saved:'%2'.\n%1 possible via context menu");
if (fromUndo)
setNotificationText(msgFormat.arg(tr("Redo")).arg(tr("Undo: %1").arg(getRedoText())));
else
setNotificationText(msgFormat.arg(tr("Undo")).arg(getUndoText()));
}
void QMLManager::openNoCloudRepo()
@ -1482,7 +1492,7 @@ void QMLManager::openNoCloudRepo()
openLocalThenRemote(filename);
}
void QMLManager::saveChangesLocal(bool fromUndo)
void QMLManager::saveChangesLocal()
{
if (unsavedChanges()) {
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NOCLOUD) {
@ -1512,21 +1522,12 @@ void QMLManager::saveChangesLocal(bool fromUndo)
mark_divelist_changed(false);
Command::setClean();
updateHaveLocalChanges(true);
// provide a useful undo/redo notification
// NOTE: the QML UI interprets a leading '[action]' (where only the two brackets are checked for)
// as an indication to use the text between those two brackets as the label of a button that
// can be used to open the context menu
QString msgFormat = tr("[%1]Changes saved:'%2'.\n%1 possible via context menu");
if (fromUndo)
setNotificationText(msgFormat.arg(tr("Redo")).arg(tr("Undo: %1").arg(getRedoText())));
else
setNotificationText(msgFormat.arg(tr("Undo")).arg(getUndoText()));
} else {
appendTextToLog("local save requested with no unsaved changes");
}
}
void QMLManager::saveChangesCloud(bool forceRemoteSync, bool fromUndo)
void QMLManager::saveChangesCloud(bool forceRemoteSync)
{
if (!unsavedChanges() && !forceRemoteSync) {
appendTextToLog("asked to save changes but no unsaved changes");
@ -1534,7 +1535,7 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync, bool fromUndo)
}
// first we need to store any unsaved changes to the local repo
gitProgressCB("Save changes to local cache");
saveChangesLocal(fromUndo);
saveChangesLocal();
// if the user asked not to push to the cloud we are done
if (git_local_only && !forceRemoteSync)
return;

View file

@ -179,7 +179,7 @@ public slots:
void addDiveToTrip(int id, int tripId);
void changesNeedSaving(bool fromUndo = false);
void openNoCloudRepo();
void saveChangesCloud(bool forceRemoteSync, bool fromUndo = false);
void saveChangesCloud(bool forceRemoteSync);
void selectDive(int id);
void deleteDive(int id);
void deleteAccount();
@ -262,7 +262,7 @@ private:
void consumeFinishedLoad();
void mergeLocalRepo();
void openLocalThenRemote(QString url);
void saveChangesLocal(bool fromUndo = false);
void saveChangesLocal();
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
QString appLogFileName;