Small fix in account deleting

This commit is contained in:
Scharel Clemens 2019-12-18 20:21:47 +01:00
parent 74ae7bd213
commit e2aaa47a7e

View file

@ -7,13 +7,13 @@ import "pages"
ApplicationWindow ApplicationWindow
{ {
id: appWindow id: appWindow
/*
ConfigurationValue { ConfigurationValue {
id: accounts id: accounts
key: appSettings.path + "/accountIDs" key: appSettings.path + "/accountIDs"
defaultValue: [ ] defaultValue: [ ]
} }
*/
ConfigurationGroup { ConfigurationGroup {
id: account id: account
path: "/apps/harbour-nextcloudnotes/accounts/" + appSettings.currentAccount path: "/apps/harbour-nextcloudnotes/accounts/" + appSettings.currentAccount
@ -63,19 +63,20 @@ ApplicationWindow
} }
function removeAccount(uuid) { function removeAccount(uuid) {
autoSyncTimer.stop() autoSyncTimer.stop()
var newIds = [ ] var confGroup = ConfigurationGroup
accountIDs.forEach(function(currentValue) { confGroup.path = "/apps/harbour-nextcloudnotes/accounts/" + uuid
if (currentValue !== uuid) {
newIds.push(currentValue)
}
})
accounts.value = newIds
for (var i = accountIDs.length-1; i >= 0; i--) { for (var i = accountIDs.length-1; i >= 0; i--) {
if (accountIDs[i] !== uuid) { if (accountIDs[i] !== uuid && appSettings.currentAccount === uuid) {
appSettings.currentAccount = uuid appSettings.currentAccount = accountIDs[i]
break }
else if (accountIDs[i] === uuid) {
accountIDs.splice(i, 1)
} }
} }
if (appSettings.currentAccount === uuid) {
appSettings.currentAccount = ""
}
confGroup.clear()
if (autoSyncInterval > 0 && appWindow.visible) { if (autoSyncInterval > 0 && appWindow.visible) {
autoSyncTimer.start() autoSyncTimer.start()
} }