From 1f7d57c2c203d363bdcb7f0dc364ca69063bea30 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 1 Aug 2013 17:24:00 -0700 Subject: [PATCH] series collection is now loaded on app start. --- NzbDrone.Api/Series/SeriesModule.cs | 12 ------------ UI/Controller.js | 17 ++++++++++++----- UI/Router.js | 10 +++++++--- UI/Series/Index/SeriesIndexLayout.js | 4 ---- UI/Series/SeriesCollection.js | 2 -- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/NzbDrone.Api/Series/SeriesModule.cs b/NzbDrone.Api/Series/SeriesModule.cs index 27ab18df0..35fc88da1 100644 --- a/NzbDrone.Api/Series/SeriesModule.cs +++ b/NzbDrone.Api/Series/SeriesModule.cs @@ -45,18 +45,6 @@ private SeriesResource GetSeries(int id) return GetSeriesResource(series); } - private Response GetSeriesBySlug(string slug) - { - var series = _seriesService.FindBySlug(slug); - - if (series == null) - { - return new NotFoundResponse(); - } - - return GetSeriesResource(series).AsResponse(); - } - private SeriesResource GetSeriesResource(Core.Tv.Series series) { if (series == null) return null; diff --git a/UI/Controller.js b/UI/Controller.js index 83c103927..b75d8cdf3 100644 --- a/UI/Controller.js +++ b/UI/Controller.js @@ -18,24 +18,31 @@ define( 'System/Layout', 'Shared/NotFoundView', 'Shared/Modal/Region' - ], function (App, Marionette, HistoryLayout, SettingsLayout, AddSeriesLayout, SeriesIndexLayout, SeriesDetailsLayout,SeriesCollection, MissingLayout, SeriesModel, CalendarLayout, + ], function (App, Marionette, HistoryLayout, SettingsLayout, AddSeriesLayout, SeriesIndexLayout, SeriesDetailsLayout, SeriesCollection, MissingLayout, SeriesModel, CalendarLayout, LogsLayout, LogFileLayout, ReleaseLayout, SystemLayout, NotFoundView) { return Marionette.Controller.extend({ - series : function () { + series: function () { this._setTitle('NzbDrone'); App.mainRegion.show(new SeriesIndexLayout()); }, seriesDetails: function (query) { + var series = SeriesCollection.where({titleSlug: query}); - var series = SeriesCollection.where({titleSlug : query}); - - if(series.length != 0){ + if (series.length != 0) { var targetSeries = series[0]; this._setTitle(targetSeries.get('title')); App.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries })); } + else { + this.notFound(); + } + }, + + + _showSeriesDetail: function(seriesModel){ + }, addSeries: function (action) { diff --git a/UI/Router.js b/UI/Router.js index d82cfb07b..f4abb0e91 100644 --- a/UI/Router.js +++ b/UI/Router.js @@ -4,8 +4,9 @@ require( 'app', 'marionette', 'Controller', + 'Series/SeriesCollection', 'jQuery/RouteBinder' - ], function (App, Marionette, Controller, RouterBinder) { + ], function (App, Marionette, Controller, SeriesCollection, RouterBinder) { var Router = Marionette.AppRouter.extend({ @@ -32,9 +33,12 @@ require( App.addInitializer(function () { App.Router = new Router(); - Backbone.history.start({ pushState: true }); - RouterBinder.bind(App.Router); + SeriesCollection.fetch() + .done(function(){ + Backbone.history.start({ pushState: true }); + RouterBinder.bind(App.Router); + }) }); return App.Router; diff --git a/UI/Series/Index/SeriesIndexLayout.js b/UI/Series/Index/SeriesIndexLayout.js index 564fe4942..fc6bedcbc 100644 --- a/UI/Series/Index/SeriesIndexLayout.js +++ b/UI/Series/Index/SeriesIndexLayout.js @@ -174,10 +174,6 @@ define( }, _fetchCollection: function () { - if (SeriesCollection.length === 0) { - this.seriesRegion.show(new LoadingView()); - } - SeriesCollection.fetch(); }, diff --git a/UI/Series/SeriesCollection.js b/UI/Series/SeriesCollection.js index 9128ea883..7c61ac73a 100644 --- a/UI/Series/SeriesCollection.js +++ b/UI/Series/SeriesCollection.js @@ -19,7 +19,5 @@ define( }); var collection = new Collection(); - collection.fetch(); - return collection; });