DEV: Remove code that is not being used.
Code was added ine15c86e8c5
but it isn't necessary anymore. Follow-up toe15c86e8c5
This commit is contained in:
parent
16ff3ea2f1
commit
2fb17b7b17
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue