refresh series details after rename/refresh

Fixed: Refresh series details after series refresh and rename
pull/32/head
Mark McDowall 11 years ago
parent c2129054a0
commit bd1a9db0ef

@ -1,13 +1,16 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'Commands/CommandModel', 'Commands/CommandModel',
'Commands/CommandCollection', 'Commands/CommandCollection',
'underscore', 'underscore',
'jQuery/jquery.spin' 'jQuery/jquery.spin'
], function (CommandModel, CommandCollection, _) { ], function (App, CommandModel, CommandCollection, _) {
return{ var singleton = function () {
return {
Execute: function (name, properties) { Execute: function (name, properties) {
@ -47,10 +50,17 @@ define(
model.bind('change:state', function (model) { model.bind('change:state', function (model) {
if (!model.isActive()) { if (!model.isActive()) {
options.element.stopSpin(); options.element.stopSpin();
if (model.isComplete()) {
App.vent.trigger(App.Events.CommandComplete, { command: model, model: options.model });
}
} }
}); });
options.element.startSpin(); options.element.startSpin();
} }
}; };
};
return singleton();
}); });

@ -11,13 +11,9 @@ define(
return response; return response;
}, },
isActive: function () {
return this.get('state') !== 'completed' && this.get('state') !== 'failed';
},
isSameCommand: function (command) { isSameCommand: function (command) {
if (command.name.toLocaleLowerCase() != this.get('name').toLocaleLowerCase()) { if (command.name.toLocaleLowerCase() !== this.get('name').toLocaleLowerCase()) {
return false; return false;
} }
@ -28,6 +24,14 @@ define(
} }
return true; return true;
},
isActive: function () {
return this.get('state') !== 'completed' && this.get('state') !== 'failed';
},
isComplete: function () {
return this.get('state') === 'completed';
} }
}); });
}); });

@ -44,6 +44,8 @@ define(
this.listenTo(this.model, 'change:monitored', this._setMonitoredState); this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
this.listenTo(App.vent, App.Events.SeriesDeleted, this._onSeriesDeleted); this.listenTo(App.vent, App.Events.SeriesDeleted, this._onSeriesDeleted);
this.listenTo(App.vent, App.Events.SeasonRenamed, this._onSeasonRenamed); this.listenTo(App.vent, App.Events.SeasonRenamed, this._onSeasonRenamed);
App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
}, },
onShow: function () { onShow: function () {
@ -195,6 +197,16 @@ define(
if (this.model.get('id') === event.series.get('id')) { if (this.model.get('id') === event.series.get('id')) {
this.episodeFileCollection.fetch(); this.episodeFileCollection.fetch();
} }
},
_commandComplete: function (options) {
if (options.command.get('name') === 'refreshseries' || options.command.get('name') === 'renameseries') {
if (options.command.get('seriesId') === this.model.get('id')) {
this._showSeasons();
this._setMonitoredState();
this._showInfo();
}
}
} }
}); });
}); });

@ -25,7 +25,6 @@ require.config({
'jquery.knob' : 'JsLibraries/jquery.knob', 'jquery.knob' : 'JsLibraries/jquery.knob',
'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot', 'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot',
'libs' : 'JsLibraries/' 'libs' : 'JsLibraries/'
}, },
shim: { shim: {
@ -192,8 +191,9 @@ define(
app.Events = { app.Events = {
SeriesAdded : 'series:added', SeriesAdded : 'series:added',
SeriesDeleted: 'series:deleted', SeriesDeleted : 'series:deleted',
SeasonRenamed: 'season:renamed' SeasonRenamed : 'season:renamed',
CommandComplete: 'command:complete'
}; };
app.Commands = { app.Commands = {

Loading…
Cancel
Save