FIX: 🐛 supress the category badge even when refreshing

This commit is contained in:
Robin Ward 2015-01-15 14:52:08 -05:00
parent 20d2908c50
commit 9c977a08cd
3 changed files with 9 additions and 12 deletions

View File

@ -50,6 +50,8 @@ var controllerOpts = {
// Lesson learned: Don't call `loading` yourself.
this.set('controllers.discovery.loading', true);
Discourse.TopicList.find(filter).then(function(list) {
Discourse.TopicList.hideUniformCategory(list, self.get('category'));
self.setProperties({ model: list, selected: [] });
var tracking = Discourse.TopicTrackingState.current();

View File

@ -1,12 +1,3 @@
/**
A data model representing a list of topics
@class TopicList
@extends Discourse.Model
@namespace Discourse
@module Discourse
**/
function finderFor(filter, params) {
return function() {
var url = Discourse.getURL("/") + filter + ".json";
@ -264,6 +255,12 @@ Discourse.TopicList.reopenClass({
return PreloadStore.getAndRemove("topic_list_" + filter, finderFor(filter, params)).then(function(result) {
return Discourse.TopicList.from(result, filter, params);
});
},
// Sets `hideCategory` if all topics in the last have a particular category
hideUniformCategory: function(list, category) {
var hideCategory = !list.get('topics').any(function (t) { return t.get('category') !== category; });
list.set('hideCategory', hideCategory);
}
});

View File

@ -54,9 +54,7 @@ export default function(filter, params) {
extras = { cached: this.isPoppedState(transition) };
return Discourse.TopicList.list(listFilter, findOpts, extras).then(function(list) {
// If all the categories are the same, we can hide them
var hideCategory = !list.get('topics').find(function (t) { return t.get('category') !== model; });
list.set('hideCategory', hideCategory);
Discourse.TopicList.hideUniformCategory(list, model);
self.set('topics', list);
});
},