FIX: Stop tracking incoming message after navigating away take 2. (#14508)

* FIX: Stop tracking incoming message after navigating away take 2.

Previous fix in d82e5cd37c resulted in
counts being flappy as we cleared the active inbox between routes.

Co-authored-by: Osama Sayegh <asooomaasoooma90@gmail.com>
This commit is contained in:
Alan Guo Xiang Tan 2021-10-05 15:00:44 +08:00 committed by GitHub
parent 085eb56ea4
commit 12856ab8c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -78,21 +78,20 @@ const PrivateMessageTopicTrackingState = EmberObject.extend({
trackIncoming(inbox, filter, group) {
this.setProperties({ inbox, filter, activeGroup: group });
this.set("isTrackingIncoming", true);
},
resetIncomingTracking() {
if (this.inbox) {
if (this.isTrackingIncoming) {
this.set("newIncoming", []);
}
},
stopIncomingTracking() {
if (this.inbox) {
if (this.isTrackingIncoming) {
this.setProperties({
isTrackingIncoming: false,
newIncoming: [],
inbox: null,
filter: null,
activeGroup: null,
});
}
},
@ -213,7 +212,7 @@ const PrivateMessageTopicTrackingState = EmberObject.extend({
},
_notifyIncoming(topicId) {
if (this.newIncoming.indexOf(topicId) === -1) {
if (this.isTrackingIncoming && this.newIncoming.indexOf(topicId) === -1) {
this.newIncoming.pushObject(topicId);
}
},

View File

@ -423,6 +423,21 @@ acceptance(
);
});
test("incoming messages is not tracked on non user messages route", async function (assert) {
await visit("/u/charlie/messages");
await visit("/t/13");
publishNewToMessageBus({ topicId: 1, userId: 5 });
await visit("/t/13"); // await re-render
await visit("/u/charlie/messages");
assert.ok(
!exists(".show-mores"),
"does not display the topic incoming info"
);
});
test("dismissing all unread messages", async function (assert) {
await visit("/u/charlie/messages/unread");