mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 00:53:57 -07:00
SaveIfChangedMixin
This commit is contained in:
parent
9a68785c26
commit
c94595b3ae
4 changed files with 43 additions and 7 deletions
|
@ -36,23 +36,26 @@ define(['app',
|
|||
|
||||
saveSettings: function () {
|
||||
var self = this;
|
||||
|
||||
//For now loop through and save all the models
|
||||
|
||||
|
||||
_.each(this.collection.models, function (model, index, list) {
|
||||
var name = model.get('name');
|
||||
var error = 'Failed to save indexer: ' + name;
|
||||
|
||||
model.save(undefined, self.syncNotification(error));
|
||||
model.saveIfChanged(self.syncNotification(undefined, error));
|
||||
});
|
||||
},
|
||||
|
||||
syncNotification: function (error) {
|
||||
syncNotification: function (success, error) {
|
||||
return {
|
||||
success: function () {
|
||||
if (success) {
|
||||
NzbDrone.Shared.Messenger.show({message: success});
|
||||
}
|
||||
},
|
||||
error : function () {
|
||||
NzbDrone.Shared.Messenger.show({message: "Couldn't Save General Settings", type: 'error'});
|
||||
if (error) {
|
||||
NzbDrone.Shared.Messenger.show({message: error, type: 'error'});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue