diff --git a/app/assets/javascripts/discourse/app/models/topic-tracking-state.js b/app/assets/javascripts/discourse/app/models/topic-tracking-state.js index 3fcbe2d9e1f..fe62df3c2c3 100644 --- a/app/assets/javascripts/discourse/app/models/topic-tracking-state.js +++ b/app/assets/javascripts/discourse/app/models/topic-tracking-state.js @@ -49,7 +49,6 @@ const TopicTrackingState = EmberObject.extend({ @on("init") _setup() { this.states = new Map(); - this.messageIncrementCallbacks = {}; this.stateChangeCallbacks = {}; this._trackedTopicLimit = 4000; }, @@ -381,7 +380,7 @@ const TopicTrackingState = EmberObject.extend({ * in-memory state. * * Any state changes will make a callback to all state change callbacks defined - * via onStateChange and all message increment callbacks defined via onMessageIncrement + * via onStateChange. * * @method sync * @param {TopicList} list @@ -410,19 +409,12 @@ const TopicTrackingState = EmberObject.extend({ incrementMessageCount() { this.incrementProperty("messageCount"); - Object.values(this.messageIncrementCallbacks).forEach((cb) => cb()); }, _generateCallbackId() { return Math.random().toString(12).substr(2, 9); }, - onMessageIncrement(cb) { - let callbackId = this._generateCallbackId(); - this.messageIncrementCallbacks[callbackId] = cb; - return callbackId; - }, - onStateChange(cb) { let callbackId = this._generateCallbackId(); this.stateChangeCallbacks[callbackId] = cb; diff --git a/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js b/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js index c910a3c6a58..56b94a82283 100644 --- a/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js +++ b/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js @@ -451,22 +451,14 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) { ]); }); - test("message count is incremented and callback is called", function (assert) { - let messageIncrementCalled = false; - trackingState.onMessageIncrement(() => { - messageIncrementCalled = true; - }); + test("message count is incremented", function (assert) { publishToMessageBus(`/unread/${currentUser.id}`, unreadTopicPayload); + assert.equal( trackingState.messageCount, 1, "message count incremented" ); - assert.equal( - messageIncrementCalled, - true, - "message increment callback called" - ); }); test("state is modified and callback is called", function (assert) { @@ -617,22 +609,14 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) { ); }); - test("message count is incremented and callback is called", function (assert) { - let messageIncrementCalled = false; - trackingState.onMessageIncrement(() => { - messageIncrementCalled = true; - }); + test("message count is incremented", function (assert) { publishToMessageBus("/new", newTopicPayload); + assert.equal( trackingState.messageCount, 1, "message count incremented" ); - assert.equal( - messageIncrementCalled, - true, - "message increment callback called" - ); }); test("state is modified and callback is called", function (assert) {