FIX: Remove dismiss read topics from PM topic tracking state. (#14287)
Follow-up to fc1fd1b416
This commit is contained in:
parent
85e95c9ec5
commit
c92818ae5f
|
@ -51,7 +51,11 @@ export default Mixin.create({
|
|||
|
||||
promise.then((result) => {
|
||||
if (result && result.topic_ids) {
|
||||
this.topicTrackingState.removeTopics(result.topic_ids);
|
||||
if (options.private_message_inbox) {
|
||||
this.pmTopicTrackingState.removeTopics(result.topic_ids);
|
||||
} else {
|
||||
this.topicTrackingState.removeTopics(result.topic_ids);
|
||||
}
|
||||
}
|
||||
|
||||
this.send("closeModal");
|
||||
|
|
|
@ -81,6 +81,15 @@ const PrivateMessageTopicTrackingState = EmberObject.extend({
|
|||
}
|
||||
},
|
||||
|
||||
removeTopics(topicIds) {
|
||||
if (!this.isTracking) {
|
||||
return;
|
||||
}
|
||||
|
||||
topicIds.forEach((topicId) => this.states.delete(topicId));
|
||||
this.incrementProperty("statesModificationCounter");
|
||||
},
|
||||
|
||||
_userChannel() {
|
||||
return `${this.CHANNEL_PREFIX}/user/${this.currentUser.id}`;
|
||||
},
|
||||
|
|
|
@ -166,7 +166,9 @@ acceptance(
|
|||
fetchUserNew = true;
|
||||
}
|
||||
|
||||
return helper.response({});
|
||||
return helper.response({
|
||||
topic_ids: [1, 2, 3],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -459,6 +461,10 @@ acceptance(
|
|||
test("dismissing all unread messages", async function (assert) {
|
||||
await visit("/u/charlie/messages/unread");
|
||||
|
||||
publishUnreadToMessageBus({ topicId: 1, userId: 5 });
|
||||
publishUnreadToMessageBus({ topicId: 2, userId: 5 });
|
||||
publishUnreadToMessageBus({ topicId: 3, userId: 5 });
|
||||
|
||||
assert.equal(
|
||||
count(".topic-list-item"),
|
||||
3,
|
||||
|
@ -468,6 +474,12 @@ acceptance(
|
|||
await click(".btn.dismiss-read");
|
||||
await click("#dismiss-read-confirm");
|
||||
|
||||
assert.equal(
|
||||
query(".messages-nav li a.unread").innerText.trim(),
|
||||
I18n.t("user.messages.unread"),
|
||||
"displays the right count"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
count(".topic-list-item"),
|
||||
0,
|
||||
|
|
Loading…
Reference in New Issue