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

Code before:
                $scope.currentSharing.selected[folders[i].id] = !!state;
            }
        };

        $scope.addDevice = function (deviceID, name) {
            return $http.get(urlbase + '/system/discovery')
                .success(function (registry) {
                    $scope.discovery = [];
                    for (var id in registry) {
                        if ($scope.discovery.length === 5) {
                            break;
                        }
                        if (id in $scope.devices) {
                            continue
                        }
                        $scope.discovery.push(id);
                    }
                })
                .then(function () {
                    $http.get(urlbase + '/config/defaults/device').then(function (p) {
                        $scope.currentDevice = p.data;
                        $scope.currentDevice.name = name;
                        $scope.currentDevice.deviceID = deviceID;
                        if (!deviceID) {
                            $scope.currentDevice._editing = "new";
                        };
                        initShareEditing('device');
                        $scope.currentSharing.unrelated = $scope.folderList();
                        editDeviceModal();
                    }, $scope.emitHTTPError);
                });
        };

        $scope.deleteDevice = function () {
            $('#editDevice').modal('hide');
            if ($scope.currentDevice._editing != "existing") {
                return;
            }

            var id = $scope.currentDevice.deviceID
            delete $scope.devices[id];
            $scope.config.devices = $scope.deviceList();

            for (var id in $scope.folders) {
                $scope.folders[id].devices = $scope.folders[id].devices.filter(function (n) {
                    return n.deviceID !== $scope.currentDevice.deviceID;
                });
            }

            $scope.saveConfig();
        };

Review comment (suggestion):
You're not setting the variable at all now, while previously you had the special `add-pending` value.  That's error prone, please go back to setting it explicitly.

I don't see the need to rename the value from "add" to "new".  It doesn't really matter what the value is, but it's usually good to keep the changes minimal.  Especially if you want to get the review process done in a reasonable time frame :wink:

Code after:
            for (var i = 0; i < folders.length; i++) {
                $scope.currentSharing.selected[folders[i].id] = !!state;
            }
        };

        $scope.addDevice = function (deviceID, name) {
            return $http.get(urlbase + '/system/discovery')
                .success(function (registry) {
                    $scope.discovery = [];
                    for (var id in registry) {
                        if ($scope.discovery.length === 5) {
                            break;
                        }
                        if (id in $scope.devices) {
                            continue
                        }
                        $scope.discovery.push(id);
                    }
                })
                .then(function () {
                    $http.get(urlbase + '/config/defaults/device').then(function (p) {
                        $scope.currentDevice = p.data;
                        $scope.currentDevice.name = name;
                        $scope.currentDevice.deviceID = deviceID;
                        if (deviceID) {
                            $scope.currentDevice._editing = "new-pending";
                        } else {
                            $scope.currentDevice._editing = "new";
                        }
                        initShareEditing('device');
                        $scope.currentSharing.unrelated = $scope.folderList();
                        editDeviceModal();
                    }, $scope.emitHTTPError);
                });
        };

        $scope.deleteDevice = function () {
            $('#editDevice').modal('hide');
            if ($scope.currentDevice._editing != "existing") {
                return;
            }

            var id = $scope.currentDevice.deviceID
            delete $scope.devices[id];
            $scope.config.devices = $scope.deviceList();

            for (var id in $scope.folders) {
                $scope.folders[id].devices = $scope.folders[id].devices.filter(function (n) {
                    return n.deviceID !== $scope.currentDevice.deviceID;
                });
            }