From 79bf1f1056562be07d71714ab7bce0d2f8a0d435 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Tue, 2 Jun 2020 23:05:19 +0200 Subject: [PATCH] gui: Preserve folder-device info on folder edit (fixes #6706) (#6707) --- gui/default/syncthing/core/syncthingController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 5c8b97731..31f51b75a 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -59,6 +59,7 @@ angular.module('syncthing.core') } catch (exception) { } $scope.folderDefaults = { + devices: [], sharedDevices: {}, selectedDevices: {}, unrelatedDevices: {}, @@ -1833,15 +1834,22 @@ angular.module('syncthing.core') $scope.saveFolder = function () { $('#editFolder').modal('hide'); var folderCfg = angular.copy($scope.currentFolder); - folderCfg.devices = []; folderCfg.selectedDevices[$scope.myID] = true; + var newDevices = []; + folderCfg.devices.forEach(function (dev) { + if (folderCfg.selectedDevices[dev.deviceID] === true) { + newDevices.push(dev); + delete folderCfg.selectedDevices[dev.deviceID]; + }; + }); for (var deviceID in folderCfg.selectedDevices) { if (folderCfg.selectedDevices[deviceID] === true) { - folderCfg.devices.push({ + newDevices.push({ deviceID: deviceID }); } } + folderCfg.devices = newDevices; delete folderCfg.sharedDevices; delete folderCfg.selectedDevices; delete folderCfg.unrelatedDevices;