FIX: better fix for #ca84c06 (#6684)

FIX: better fix for #ca84c06 (#6684)

From 7f089f07a773c2d6dd26ed000ff0123318c37b0f Mon Sep 17 00:00:00 2001
From: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Date: Tue, 27 Nov 2018 16:12:07 +0100
Subject: [PATCH] FIX: better fix for #ca84c06 (#6684)


diff --git a/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6 b/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6
index 7cee0c8..4d86d44 100644
--- a/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6
+++ b/app/assets/javascripts/discourse/models/topic-tracking-state.js.es6
@@ -373,7 +373,8 @@ const TopicTrackingState = Discourse.Model.extend({
 
   countCategory(category_id) {
     let sum = 0;
-    _.each(this.states, topic => {
+    Object.keys(this.states).forEach(topicState => {
+      const topic = this.states[topicState];
       if (topic.category_id === category_id && !topic.deleted) {
         sum +=
           topic.last_read_post_number === null ||

GitHub

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

This commit has been mentioned on Discourse Meta. There might be relevant details there:

Hmm going to mark this for a followup cause I am curious @eviltrout / @jjaffeux

Can we just add add a polyfill for Object.entries?

image

It is only missing in IE :confetti_ball:

I’ve considered doing it before, but it’s so easy to do Object.keys(obj).forEach(key => arr[key]) that I’ve never bothered. Considering it’s only in IE though, maybe it’s worth it.

Looks like we already have entries polyfilled, but oddly we are missing Object.values I am sweeping through and introducing it to places (including this spot) in a followup commit

2 Likes

Followed up in:

2 Likes