Series detials fixes

Fixed: Adding a new series and going to series details will show data after information is fetched
Fixed: Series details won't reload view after update
This commit is contained in:
Mark McDowall
2014-11-06 07:34:15 -08:00
parent 48ec113598
commit b6fc490b89
6 changed files with 87 additions and 34 deletions
+38 -23
View File
@@ -7,6 +7,7 @@ define(
'reqres',
'marionette',
'backbone',
'Series/SeriesCollection',
'Series/EpisodeCollection',
'Series/EpisodeFileCollection',
'Series/SeasonCollection',
@@ -22,6 +23,7 @@ define(
reqres,
Marionette,
Backbone,
SeriesCollection,
EpisodeCollection,
EpisodeFileCollection,
SeasonCollection,
@@ -57,9 +59,18 @@ define(
},
initialize: function () {
this.seriesCollection = SeriesCollection.clone();
this.seriesCollection.shadowCollection.bindSignalR();
this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
this.listenTo(vent, vent.Events.SeriesDeleted, this._onSeriesDeleted);
this.listenTo(this.model, 'remove', this._seriesRemoved);
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
this.listenTo(this.model, 'change', function (model, options) {
if (options && options.changeSource === 'signalr') {
this._refresh();
}
});
},
onShow: function () {
@@ -96,23 +107,13 @@ define(
CommandController.bindToCommand({
element: this.ui.rename,
command: {
name : 'renameFiles',
seriesId : this.model.id,
seasonNumber: -1
name : 'renameFiles',
seriesId : this.model.id,
seasonNumber : -1
}
});
},
_getFanArt: function () {
var fanArt = _.where(this.model.get('images'), {coverType: 'fanart'});
if (fanArt && fanArt[0]) {
return fanArt[0].url;
}
return undefined;
},
onClose: function () {
if (this._backstrech) {
@@ -124,6 +125,16 @@ define(
reqres.removeHandler(reqres.Requests.GetEpisodeFileById);
},
_getFanArt: function () {
var fanArt = _.where(this.model.get('images'), {coverType: 'fanart'});
if (fanArt && fanArt[0]) {
return fanArt[0].url;
}
return undefined;
},
_toggleMonitored: function () {
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {
wait: true
@@ -160,11 +171,8 @@ define(
});
},
_onSeriesDeleted: function (event) {
if (this.model.get('id') === event.series.get('id')) {
Backbone.history.navigate('/', { trigger: true });
}
_seriesRemoved: function () {
Backbone.history.navigate('/', { trigger: true });
},
_renameSeries: function () {
@@ -215,13 +223,20 @@ define(
},
_commandComplete: function (options) {
if (options.command.get('name') === 'refreshseries' || options.command.get('name') === 'renamefiles') {
if (options.command.get('name') === 'renamefiles') {
if (options.command.get('seriesId') === this.model.get('id')) {
this._showSeasons();
this._setMonitoredState();
this._showInfo();
this._refresh();
}
}
},
_refresh: function () {
this.seasonCollection.add(this.model.get('seasons'), { merge: true });
this.episodeCollection.fetch();
this.episodeFileCollection.fetch();
this._setMonitoredState();
this._showInfo();
}
});
});