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;
if (self.cb) {
var settings = {};
// no need to send in default values, just the changed ones
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) {
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);
@ -152,11 +155,15 @@ angular
if (cb) {
parseFiles(self.files, function(txts) {
var settings = {};
// no need to send in default values, just the changed ones
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) {
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);

View File

@ -103,19 +103,22 @@ angular
}
modals.invoke(
'settings', settings,
'Global Settings', 'Save', function(settings) {
'settings', _.cloneDeep(settings),
'Global Settings', 'Save', function(chsettings) {
var sets = {};
var starred = [];
for (var i in settings) {
sets[i] = settings[i].val
for (var i in chsettings) {
// 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);
}
};
console.log('saving aria2 settings:', sets);
console.log('saving aria2 starred:', starred);
rpc.once('changeGlobalOption', [sets]);