1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-23 02:05:27 +02:00
Sonarr/src/UI/Settings/SettingsModelBase.js
Mark McDowall cc66077943 Cancelling adding an indexer will stop listening to save event
Fixed: Cancelling adding indexer will not break saving
2014-01-29 21:52:50 -08:00

41 lines
1.1 KiB
JavaScript

'use strict';
define(
[
'vent',
'backbone.deepmodel',
'Mixins/AsChangeTrackingModel',
'Shared/Messenger'
], function (vent, DeepModel, AsChangeTrackingModel, Messenger) {
var model = DeepModel.DeepModel.extend({
initialize: function () {
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
this.listenTo(this, 'destroy', this._stopListening);
},
saveSettings: function () {
if (!this.isSaved) {
var savePromise = this.save();
Messenger.monitor({
promise : savePromise,
successMessage: this.successMessage,
errorMessage : this.errorMessage
});
return savePromise;
}
return undefined;
},
_stopListening: function () {
this.stopListening(vent, vent.Commands.SaveSettings);
}
});
return AsChangeTrackingModel.call(model);
});