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

Code before:
                        name: rejected.name,
                        address: rejected.address
                    };
                    console.log("rejected device:", rejected.deviceID, pendingDevice);
                    $scope.pendingDevices[rejected.deviceID] = pendingDevice;
                });
            }

            if (arg.data.removed) {
                arg.data.removed.forEach(function (dev) {
                    console.log("no longer pending device:", dev.deviceID);
                    delete $scope.pendingDevices[dev.deviceID];
                });
            }
        });

        $scope.$on(Events.PENDING_FOLDERS_CHANGED, function (event, arg) {
            if (!(arg.data.added || arg.data.removed)) {
                // Not enough information to update in place, just refresh it completely
                refreshCluster();
                return;
            }

            if (arg.data.added) {
                arg.data.added.forEach(function (rejected) {
                    var observedFolder = {
                        time: arg.time,
                        label: rejected.folderLabel,
                        receiveEncrypted: rejected.receiveEncrypted,
                    };
                    console.log("rejected folder", rejected.folderID, "from device:", rejected.deviceID, observedFolder);

                    var pendingFolder = $scope.pendingFolders[rejected.folderID];
                    if (pendingFolder === undefined) {
                        pendingFolder = {
                            offeredBy: {}
                        };
                    }
                    pendingFolder.offeredBy[rejected.deviceID] = observedFolder;
                    $scope.pendingFolders[rejected.folderID] = pendingFolder;
                });
            }

            if (arg.data.removed) {
                arg.data.removed.forEach(function (folderDev) {
                    console.log("no longer pending folder", folderDev.folderID, "from device:", folderDev.deviceID);
                    if (folderDev.deviceID === undefined) {
                        delete $scope.pendingFolders[folderDev.folderID];
                    } else if ($scope.pendingFolders[folderDev.folderID]) {
                        delete $scope.pendingFolders[folderDev.folderID].offeredBy[folderDev.deviceID];
                    }

Review comment (suggestion):
I can see why you might want to rename this, matching the DB's `ObservedFolder` type.  But for consistency in the GUI code, I would keep the `offeringDevice` naming, because the rejection is always specific to the device, and `observedFolder` next to `pendingFolder` is more confusing IMO.

Just a suggestion though, I'm okay with the rename if it's clearer to you this way.

Code after:
                arg.data.added.forEach(function (rejected) {
                    var pendingDevice = {
                        time: arg.time,
                        name: rejected.name,
                        address: rejected.address
                    };
                    console.log("rejected device:", rejected.deviceID, pendingDevice);
                    $scope.pendingDevices[rejected.deviceID] = pendingDevice;
                });
            }

            if (arg.data.removed) {
                arg.data.removed.forEach(function (dev) {
                    console.log("no longer pending device:", dev.deviceID);
                    delete $scope.pendingDevices[dev.deviceID];
                });
            }
        });

        $scope.$on(Events.PENDING_FOLDERS_CHANGED, function (event, arg) {
            if (!(arg.data.added || arg.data.removed)) {
                // Not enough information to update in place, just refresh it completely
                refreshCluster();
                return;
            }

            if (arg.data.added) {
                arg.data.added.forEach(function (rejected) {
                    var offeringDevice = {
                        time: arg.time,
                        label: rejected.folderLabel,
                        receiveEncrypted: rejected.receiveEncrypted,
                    };
                    console.log("rejected folder", rejected.folderID, "from device:", rejected.deviceID, offeringDevice);

                    var pendingFolder = $scope.pendingFolders[rejected.folderID];
                    if (pendingFolder === undefined) {
                        pendingFolder = {
                            offeredBy: {}
                        };
                    }
                    pendingFolder.offeredBy[rejected.deviceID] = offeringDevice;
                    $scope.pendingFolders[rejected.folderID] = pendingFolder;
                });
            }

            if (arg.data.removed) {
                arg.data.removed.forEach(function (folderDev) {
                    console.log("no longer pending folder", folderDev.folderID, "from device:", folderDev.deviceID);
                    if (folderDev.deviceID === undefined) {
                        delete $scope.pendingFolders[folderDev.folderID];