Repository: syncthing/syncthing (language: go)

Issue:
gui: Save settings broken since #7530
Something changed in #7530 that broke saving settings.  At least I cannot change the theme anymore, some JavaScript errors are popping up.

One obvious thing is in https://github.com/syncthing/syncthing/blob/21d04b895a7b3ee0803e36e4f0b3f5e8e6cf1379/gui/default/syncthing/core/syncthingController.js#L1516: `saveConfig.then()` is missing the parentheses to actually call the function and make the promise.

After fixing this, I encountered errors because `emitHTTPError()` is called with a null argument for data, from somewhere around `refreshSystem()` if I interpret it correctly.  Please have a look @imsodin what is going on there.  Sorry I didn't test this during review, and my experience with JS promises is too limited to notice.

To reproduce, open Settings, change the GUI theme, save.


Discussion / hints:
There's also some `Error: Promised response from onMessage listener went out of scope` messages sprinkled in between... That's where my JS debugging skills currently end :-(

Fix patch:
diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js
index 1e6e20ef05d..74b7a5e36d5 100755
--- a/gui/default/syncthing/core/syncthingController.js
+++ b/gui/default/syncthing/core/syncthingController.js
@@ -1513,7 +1513,7 @@ angular.module('syncthing.core')
                 // here as well...
                 $scope.devices = deviceMap($scope.config.devices);
 
-                $scope.saveConfig.then(function () {
+                $scope.saveConfig().then(function () {
                     if (themeChanged) {
                         document.location.reload(true);
                     }


Test patch: