1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-10 23:29:53 +02:00
Sonarr/src/UI/Settings/SettingsModelBase.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'use strict';
2013-10-09 04:43:41 +03:00
define(
[
'vent',
'backbone.deepmodel',
'Mixins/AsChangeTrackingModel',
'Shared/Messenger'
], function (vent, DeepModel, AsChangeTrackingModel, Messenger) {
var model = DeepModel.DeepModel.extend({
2013-10-09 04:43:41 +03:00
initialize: function () {
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
this.listenTo(this, 'destroy', this._stopListening);
2013-10-09 04:43:41 +03:00
},
2013-10-09 04:43:41 +03:00
saveSettings: function () {
2013-10-09 04:43:41 +03:00
if (!this.isSaved) {
2013-10-09 04:43:41 +03:00
var savePromise = this.save();
2013-10-09 04:43:41 +03:00
Messenger.monitor({
promise : savePromise,
successMessage: this.successMessage,
errorMessage : this.errorMessage
});
2013-10-09 04:43:41 +03:00
return savePromise;
}
return undefined;
},
_stopListening: function () {
this.stopListening(vent, vent.Commands.SaveSettings);
}
2013-10-09 04:43:41 +03:00
});
2013-10-09 04:43:41 +03:00
return AsChangeTrackingModel.call(model);
});