From 86ea33b6387c5f55b41968fd7594e2bb85e3bd06 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 7 Oct 2013 23:03:00 -0700 Subject: [PATCH] Episode details uses listenTo instead of promises --- src/UI/Episode/EpisodeDetailsLayout.js | 10 +++------ src/UI/Episode/Search/EpisodeSearchLayout.js | 22 ++++++++------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/UI/Episode/EpisodeDetailsLayout.js b/src/UI/Episode/EpisodeDetailsLayout.js index fe60cad1b..bc17cd0c1 100644 --- a/src/UI/Episode/EpisodeDetailsLayout.js +++ b/src/UI/Episode/EpisodeDetailsLayout.js @@ -40,6 +40,8 @@ define( this.series = SeriesCollection.find({ id: this.model.get('seriesId') }); this.templateHelpers.series = this.series.toJSON(); this.openingTab = options.openingTab || 'summary'; + + this.listenTo(this.model, 'sync', this._setMonitoredState); }, onShow: function () { @@ -85,17 +87,11 @@ define( }, _toggleMonitored: function () { - var self = this; var name = 'monitored'; this.model.set(name, !this.model.get(name), { silent: true }); this.ui.monitored.addClass('icon-spinner icon-spin'); - - var promise = this.model.save(); - - promise.always(function () { - self._setMonitoredState(); - }); + this.model.save(); }, _setMonitoredState: function () { diff --git a/src/UI/Episode/Search/EpisodeSearchLayout.js b/src/UI/Episode/Search/EpisodeSearchLayout.js index e346dac44..a58c5db41 100644 --- a/src/UI/Episode/Search/EpisodeSearchLayout.js +++ b/src/UI/Episode/Search/EpisodeSearchLayout.js @@ -26,6 +26,9 @@ define( initialize: function () { this.mainView = new ButtonsView(); + this.releaseCollection = new ReleaseCollection(); + + this.listenTo(this.releaseCollection, 'sync', this._showSearchResults); }, onShow: function () { @@ -55,20 +58,9 @@ define( e.preventDefault(); } - var self = this; - this.mainView = new LoadingView(); this._showMainView(); - - var releases = new ReleaseCollection(); - var promise = releases.fetchEpisodeReleases(this.model.id); - - promise.done(function () { - if (!self.isClosed) { - self.mainView = new ManualSearchLayout({collection: releases}); - self._showMainView(); - } - }); + this.releaseCollection.fetchEpisodeReleases(this.model.id); }, _showMainView: function () { @@ -78,7 +70,11 @@ define( _showButtons: function () { this.mainView = new ButtonsView(); this._showMainView(); + }, + + _showSearchResults: function () { + this.mainView = new ManualSearchLayout({ collection: this.releaseCollection }); + this._showMainView(); } }); - });