DEV: Remove code that is not being used.

Code was added in e15c86e8c5 but it isn't
necessary anymore.

Follow-up to e15c86e8c5
This commit is contained in:
Alan Guo Xiang Tan 2021-08-11 15:40:59 +08:00
parent 16ff3ea2f1
commit 2fb17b7b17
2 changed files with 5 additions and 29 deletions

View File

@ -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;

View File

@ -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) {