Repository: syncthing/syncthing
File: gui/default/syncthing/core/syncthingController.js (JavaScript)

Code before:
                    protocol = 'https';
                }

                setTimeout(function () {
                    window.location.protocol = protocol;
                }, 2500);

                $scope.protocolChanged = false;
            }
        };

        $scope.upgrade = function () {
            restarting = true;
            hideModal('#upgrade');
            hideModal('#majorUpgrade');
            showModal('#upgrading');
            $http.post(urlbase + '/system/upgrade').success(function () {
                hideModal('#upgrading');
                showModal('#restarting');
            }).error(function () {
                hideModal('#upgrading');
            });
        };

        $scope.shutdown = function () {
            restarting = true;
            $http.post(urlbase + '/system/shutdown').success(function () {
                showModal('#shutdown');
            }).error($scope.emitHTTPError);
            $scope.configInSync = true;
        };

        function editDeviceModal() {
            $scope.currentDevice._addressesStr = $scope.currentDevice.addresses.join(', ');
            $scope.deviceEditor.$setPristine();
            showModal('#editDevice');
        }

        $scope.editDeviceModalTitle = function() {
            if ($scope.editingDeviceDefaults()) {
                return $translate.instant("Edit Device Defaults");
            }
            var title = '';
            if ($scope.editingDeviceExisting()) {
                title += $translate.instant("Edit Device");
            } else {
                title += $translate.instant("Add Device");
            }
            var name = $scope.deviceName($scope.currentDevice);
            if (name !== '') {
                title += ' (' + name + ')';

Review comment (bug):
Just for the record, the order here has been changed on purpose. It doesn't make sense to show the next modal first, and only then hide the previous one. Plus, doing so would also cause the body padding increase bug. Not that it matters much when the GUI is going to reload after the restart anyway.

Code after:
            $scope.configInSync = true;

            // Switch webpage protocol if needed
            if ($scope.protocolChanged) {
                var protocol = 'http';

                if ($scope.config.gui.useTLS) {
                    protocol = 'https';
                }

                setTimeout(function () {
                    window.location.protocol = protocol;
                }, 2500);

                $scope.protocolChanged = false;
            }
        };

        $scope.upgrade = function () {
            restarting = true;
            hideModal('#upgrade');
            hideModal('#majorUpgrade');
            showModal('#upgrading');
            $http.post(urlbase + '/system/upgrade').success(function () {
                hideModal('#upgrading');
                showModal('#restarting');
            }).error(function () {
                hideModal('#upgrading');
            });
        };

        $scope.shutdown = function () {
            restarting = true;
            $http.post(urlbase + '/system/shutdown').success(function () {
                showModal('#shutdown');
            }).error($scope.emitHTTPError);
            $scope.configInSync = true;
        };

        function editDeviceModal() {
            $scope.currentDevice._addressesStr = $scope.currentDevice.addresses.join(', ');
            $scope.deviceEditor.$setPristine();
            showModal('#editDevice');
        }

        $scope.editDeviceModalTitle = function() {
            if ($scope.editingDeviceDefaults()) {
                return $translate.instant("Edit Device Defaults");
            }
            var title = '';
            if ($scope.editingDeviceExisting()) {