From e2aaa47a7e45cf0a9ae9abf3396740105cf65f1e Mon Sep 17 00:00:00 2001 From: Scharel Clemens Date: Wed, 18 Dec 2019 20:21:47 +0100 Subject: [PATCH] Small fix in account deleting --- qml/harbour-nextcloudnotes.qml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/qml/harbour-nextcloudnotes.qml b/qml/harbour-nextcloudnotes.qml index eb3ba3a..5605b2f 100644 --- a/qml/harbour-nextcloudnotes.qml +++ b/qml/harbour-nextcloudnotes.qml @@ -7,13 +7,13 @@ import "pages" ApplicationWindow { id: appWindow - + /* ConfigurationValue { id: accounts key: appSettings.path + "/accountIDs" defaultValue: [ ] } - + */ ConfigurationGroup { id: account path: "/apps/harbour-nextcloudnotes/accounts/" + appSettings.currentAccount @@ -63,19 +63,20 @@ ApplicationWindow } function removeAccount(uuid) { autoSyncTimer.stop() - var newIds = [ ] - accountIDs.forEach(function(currentValue) { - if (currentValue !== uuid) { - newIds.push(currentValue) - } - }) - accounts.value = newIds + var confGroup = ConfigurationGroup + confGroup.path = "/apps/harbour-nextcloudnotes/accounts/" + uuid for (var i = accountIDs.length-1; i >= 0; i--) { - if (accountIDs[i] !== uuid) { - appSettings.currentAccount = uuid - break + if (accountIDs[i] !== uuid && appSettings.currentAccount === uuid) { + appSettings.currentAccount = accountIDs[i] + } + else if (accountIDs[i] === uuid) { + accountIDs.splice(i, 1) } } + if (appSettings.currentAccount === uuid) { + appSettings.currentAccount = "" + } + confGroup.clear() if (autoSyncInterval > 0 && appWindow.visible) { autoSyncTimer.start() }