only update aria2 download and global settings when they change

This commit is contained in:
hamza zia 2014-07-03 01:04:03 +08:00
parent 87f807a5fe
commit 091fbb0d41
2 changed files with 19 additions and 9 deletions

View File

@ -57,11 +57,14 @@ angular
delete self.inst; delete self.inst;
if (self.cb) { if (self.cb) {
var settings = {}; var settings = {};
// no need to send in default values, just the changed ones
for (var i in self.settings) { for (var i in self.settings) {
settings[i] = self.settings[i].val; if (fsettings[i].val != self.settings[i].val)
settings[i] = self.settings[i].val;
} }
for (var i in self.fsettings) { for (var i in self.fsettings) {
settings[i] = self.fsettings[i].val; if (fsettings[i].val != self.fsettings[i].val)
settings[i] = self.fsettings[i].val;
} }
console.log('sending settings:', settings); console.log('sending settings:', settings);
@ -152,11 +155,15 @@ angular
if (cb) { if (cb) {
parseFiles(self.files, function(txts) { parseFiles(self.files, function(txts) {
var settings = {}; var settings = {};
// no need to send in default values, just the changed ones
for (var i in self.settings) { for (var i in self.settings) {
settings[i] = self.settings[i].val; if (fsettings[i].val != self.settings[i].val)
settings[i] = self.settings[i].val;
} }
for (var i in self.fsettings) { for (var i in self.fsettings) {
settings[i] = self.fsettings[i].val; if (fsettings[i].val != self.fsettings[i].val)
settings[i] = self.fsettings[i].val;
} }
console.log('sending settings:', settings); console.log('sending settings:', settings);

View File

@ -103,19 +103,22 @@ angular
} }
modals.invoke( modals.invoke(
'settings', settings, 'settings', _.cloneDeep(settings),
'Global Settings', 'Save', function(settings) { 'Global Settings', 'Save', function(chsettings) {
var sets = {}; var sets = {};
var starred = []; var starred = [];
for (var i in settings) { for (var i in chsettings) {
sets[i] = settings[i].val // no need to change default values
if (settings[i].val != chsettings[i].val)
sets[i] = chsettings[i].val
if (settings[i].starred) { if (chsettings[i].starred) {
starred.push(i); starred.push(i);
} }
}; };
console.log('saving aria2 settings:', sets);
console.log('saving aria2 starred:', starred); console.log('saving aria2 starred:', starred);
rpc.once('changeGlobalOption', [sets]); rpc.once('changeGlobalOption', [sets]);