MCPcopy Index your code
hub / github.com/syncthing/syncthing / updateLocalConfig

Function updateLocalConfig

gui/default/syncthing/core/syncthingController.js:555–613  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

553 }
554
555 function updateLocalConfig(config) {
556 var hasConfig = !isEmptyObject($scope.config);
557
558 $scope.config = config;
559 $scope.config.options._listenAddressesStr = $scope.config.options.listenAddresses.join(', ');
560 $scope.config.options._globalAnnounceServersStr = $scope.config.options.globalAnnounceServers.join(', ');
561 $scope.config.options._urAcceptedStr = "" + $scope.config.options.urAccepted;
562
563 $scope.devices = deviceMap($scope.config.devices);
564 for (var id in $scope.devices) {
565 $scope.completion[id] = {
566 _total: 100,
567 _needBytes: 0,
568 _needItems: 0
569 };
570
571 };
572
573 // myID is watched as $scope.otherDevices() relies on this
574 // and it can potenitally not be loaded due to this function
575 // scope being called in an undetermistic manner
576 $scope.$watch('myID', function(myID) {
577 if (myID) {
578 $scope.devicesGrouped = {};
579 const otherDevices = $scope.otherDevices();
580 for (var id in otherDevices) {
581 if ($scope.devicesGrouped[otherDevices[id].group] === undefined) {
582 $scope.devicesGrouped[otherDevices[id].group] = [];
583 }
584 $scope.devicesGrouped[otherDevices[id].group].push(otherDevices[id]);
585 };
586
587 $scope.devicesGrouped = sortByKeyThenProperty($scope.devicesGrouped, "name", "deviceID");
588 }
589 });
590
591 $scope.folders = folderMap($scope.config.folders);
592 $scope.foldersGrouped = {};
593 Object.keys($scope.folders).forEach(function (folder) {
594 refreshFolder(folder);
595 $scope.folders[folder].devices.forEach(function (deviceCfg) {
596 refreshCompletion(deviceCfg.deviceID, folder);
597 });
598
599 if ($scope.foldersGrouped[$scope.folders[folder].group] === undefined) {
600 $scope.foldersGrouped[$scope.folders[folder].group] = [];
601 }
602 $scope.foldersGrouped[$scope.folders[folder].group].push($scope.folders[folder]);
603 });
604
605 $scope.foldersGrouped = sortByKeyThenProperty($scope.foldersGrouped, "label", "id");
606
607 refreshNoAuthWarning();
608 setDefaultTheme();
609
610 if (!hasConfig) {
611 $scope.$emit('ConfigLoaded');
612 }

Callers 2

refreshConfigFunction · 0.85

Calls 9

isEmptyObjectFunction · 0.85
deviceMapFunction · 0.85
sortByKeyThenPropertyFunction · 0.85
folderMapFunction · 0.85
refreshFolderFunction · 0.85
refreshCompletionFunction · 0.85
refreshNoAuthWarningFunction · 0.85
setDefaultThemeFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected