FIX: Double clicking the home logo could leave you in a perpetual

"Loading" state.
This commit is contained in:
Robin Ward 2014-04-11 11:55:05 -04:00
parent 6b0cae8910
commit 0b42228663
5 changed files with 23 additions and 7 deletions

View File

@ -7,7 +7,7 @@
@module Discourse
**/
Discourse.DiscoveryCategoriesController = Discourse.DiscoveryController.extend({
needs: ['modal'],
needs: ['modal', 'discovery'],
actions: {
toggleOrdering: function(){
@ -16,6 +16,10 @@ Discourse.DiscoveryCategoriesController = Discourse.DiscoveryController.extend({
refresh: function() {
var self = this;
// Don't refresh if we're still loading
if (this.get('controllers.discovery.loading')) { return; }
this.send('loading');
Discourse.CategoryList.list('categories').then(function(list) {
self.set('model', list);

View File

@ -7,10 +7,15 @@
@module Discourse
**/
Discourse.DiscoveryTopController = Discourse.DiscoveryController.extend({
needs: ['discovery'],
actions: {
refresh: function() {
var self = this;
// Don't refresh if we're still loading
if (this.get('controllers.discovery.loading')) { return; }
this.send('loading');
Discourse.TopList.find().then(function(top_lists) {
self.set('model', top_lists);

View File

@ -7,6 +7,7 @@
@module Discourse
**/
Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
needs: ['discovery'],
bulkSelectEnabled: false,
selected: [],
@ -25,6 +26,9 @@ Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
var filter = this.get('model.filter'),
self = this;
// Don't refresh if we're still loading
if (this.get('controllers.discovery.loading')) { return; }
this.send('loading');
Discourse.TopicList.find(filter).then(function(list) {
self.setProperties({ model: list, selected: [] });

View File

@ -12,16 +12,19 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.OpenComposer, {
loading: function() {
var controller = this.controllerFor('discovery');
// If we're already loading don't do anything
if (controller.get('loading')) { return; }
controller.set('loading', true);
controller.set('scheduledSpinner', Ember.run.later(controller, function() {
this.set('loading', true);
this.set('loadingSpinner', true);
},500));
},
loadingComplete: function() {
var controller = this.controllerFor('discovery');
Ember.run.cancel(controller.get('scheduledSpinner'));
controller.set('loading', false);
controller.setProperties({ loading: false, loadingSpinner: false });
},
didTransition: function() {

View File

@ -9,11 +9,11 @@
</div>
</div>
<div {{bind-attr class="loading::hidden"}}>
<div {{bind-attr class="loadingSpinner::hidden"}}>
<div class='spinner'>{{i18n loading}}</div>
</div>
<div {{bind-attr class=":container :list-container loading:hidden"}}>
<div {{bind-attr class=":container :list-container loadingSpinner:hidden"}}>
<div class="row">
<div class="full-width">
<div id='list-area'>