FIX: return 0 if we are unable to count unread/new topics
This commit is contained in:
parent
64d1c91179
commit
f019f5a62d
|
@ -236,6 +236,7 @@ const TopicTrackingState = Discourse.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
countNew(category_id) {
|
countNew(category_id) {
|
||||||
|
if (this.tooManyTracked()) { return(0); }
|
||||||
return _.chain(this.states)
|
return _.chain(this.states)
|
||||||
.where(isNew)
|
.where(isNew)
|
||||||
.where(topic => topic.category_id === category_id || !category_id)
|
.where(topic => topic.category_id === category_id || !category_id)
|
||||||
|
@ -256,6 +257,7 @@ const TopicTrackingState = Discourse.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
countUnread(category_id) {
|
countUnread(category_id) {
|
||||||
|
if (this.tooManyTracked()) { return(0); }
|
||||||
return _.chain(this.states)
|
return _.chain(this.states)
|
||||||
.where(isUnread)
|
.where(isUnread)
|
||||||
.where(topic => topic.category_id === category_id || !category_id)
|
.where(topic => topic.category_id === category_id || !category_id)
|
||||||
|
@ -264,6 +266,7 @@ const TopicTrackingState = Discourse.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
countCategory(category_id) {
|
countCategory(category_id) {
|
||||||
|
if (this.tooManyTracked()) { return(0); }
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
_.each(this.states, function(topic){
|
_.each(this.states, function(topic){
|
||||||
if (topic.category_id === category_id) {
|
if (topic.category_id === category_id) {
|
||||||
|
|
Loading…
Reference in New Issue