Clear episode file change event in episode status cell
This commit is contained in:
parent
26af2b0056
commit
69c680ed87
|
@ -22,6 +22,11 @@ define(
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderCell: function () {
|
_renderCell: function () {
|
||||||
|
|
||||||
|
if (this.episodeFile) {
|
||||||
|
this.stopListening(this.episodeFile, 'change', this._refresh);
|
||||||
|
}
|
||||||
|
|
||||||
this.$el.empty();
|
this.$el.empty();
|
||||||
|
|
||||||
if (this.model) {
|
if (this.model) {
|
||||||
|
@ -30,23 +35,13 @@ define(
|
||||||
var tooltip;
|
var tooltip;
|
||||||
|
|
||||||
var hasAired = moment(this.model.get('airDateUtc')).isBefore(moment());
|
var hasAired = moment(this.model.get('airDateUtc')).isBefore(moment());
|
||||||
var hasFile = this.model.get('hasFile');
|
this.episodeFile = this._getFile();
|
||||||
|
|
||||||
if (hasFile) {
|
if (this.episodeFile) {
|
||||||
var episodeFile;
|
this.listenTo(this.episodeFile, 'change', this._refresh);
|
||||||
|
|
||||||
if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
var quality = this.episodeFile.get('quality');
|
||||||
episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
|
var size = FormatHelpers.bytes(this.episodeFile.get('size'));
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
episodeFile = new Backbone.Model(this.model.get('episodeFile'));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.listenTo(episodeFile, 'change', this._refresh);
|
|
||||||
|
|
||||||
var quality = episodeFile.get('quality');
|
|
||||||
var size = FormatHelpers.bytes(episodeFile.get('size'));
|
|
||||||
var title = 'Episode downloaded';
|
var title = 'Episode downloaded';
|
||||||
|
|
||||||
if (quality.proper) {
|
if (quality.proper) {
|
||||||
|
@ -103,6 +98,28 @@ define(
|
||||||
|
|
||||||
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_getFile: function () {
|
||||||
|
var hasFile = this.model.get('hasFile');
|
||||||
|
|
||||||
|
if (hasFile) {
|
||||||
|
var episodeFile;
|
||||||
|
|
||||||
|
if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
||||||
|
episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
episodeFile = new Backbone.Model(this.model.get('episodeFile'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (episodeFile) {
|
||||||
|
return episodeFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,9 @@ define(
|
||||||
var promise = this.model.save();
|
var promise = this.model.save();
|
||||||
|
|
||||||
promise.always(function () {
|
promise.always(function () {
|
||||||
self.ui.indicator.hide();
|
if (!self.isClosed) {
|
||||||
|
self.ui.indicator.hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
promise.done(function () {
|
promise.done(function () {
|
||||||
|
|
Loading…
Reference in New Issue