DEV: Let unread topics come through to /new when new new view is enabled (#20628)

Currently, if a user has opted into the new new experiment (introduced in a509441) and they click on the "See # new or updated topics" banner (screenshot below) at the top of the /new topics list, only new topics are loaded even if there are tracked topics with new replies.

This is unexpected in the new new view experiment because /new in this experiment is supposed to show both new and unread topics so it should listen for both new topics and new replies for existing/tracked topics. This PR addresses this inconsistency and makes it so that clicking the banner load all new and updated topics.
This commit is contained in:
Osama Sayegh 2023-03-10 04:57:35 +03:00 committed by GitHub
parent 0df7743d78
commit 118ce348f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 8 deletions

View File

@ -8,9 +8,14 @@ export default Component.extend({
didReceiveAttrs() { didReceiveAttrs() {
this._super(...arguments); this._super(...arguments);
this.set(
"i18nCount", let fullKey = this.key + (this.suffix || "");
htmlSafe(I18n.t(this.key + (this.suffix || ""), { count: this.count })) if (
); this.currentUser?.new_new_view_enabled &&
fullKey === "topic_count_new"
) {
fullKey = "topic_count_latest";
}
this.set("i18nCount", htmlSafe(I18n.t(fullKey, { count: this.count })));
}, },
}); });

View File

@ -284,11 +284,12 @@ const TopicTrackingState = EmberObject.extend({
this._addIncoming(data.topic_id); this._addIncoming(data.topic_id);
} }
const unreadRecipients = ["all", "unread", "unseen"];
if (this.currentUser?.new_new_view_enabled) {
unreadRecipients.push("new");
}
// count an unread topic as incoming // count an unread topic as incoming
if ( if (unreadRecipients.includes(filter) && data.message_type === "unread") {
["all", "unread", "unseen"].includes(filter) &&
data.message_type === "unread"
) {
const old = this.findState(data); const old = this.findState(data);
// the highest post number is equal to last read post number here // the highest post number is equal to last read post number here

View File

@ -893,6 +893,42 @@ module("Unit | Model | topic-tracking-state | /unread", function (hooks) {
); );
}); });
test("adds unread incoming to the new topic list if new new view is enabled", async function (assert) {
this.currentUser.new_new_view_enabled = true;
this.trackingState.trackIncoming("new");
await publishToMessageBus("/unread", unreadTopicPayload);
assert.deepEqual(
this.trackingState.newIncoming,
[111],
"unread topic is incoming"
);
assert.strictEqual(
this.trackingState.incomingCount,
1,
"incoming count is increased"
);
});
test("doesn't add unread incoming to the new topic list if new new view is disabled", async function (assert) {
this.currentUser.new_new_view_enabled = false;
this.trackingState.trackIncoming("new");
await publishToMessageBus("/unread", unreadTopicPayload);
assert.deepEqual(
this.trackingState.newIncoming,
[],
"unread topic is not incoming"
);
assert.strictEqual(
this.trackingState.incomingCount,
0,
"incoming count isn't increased"
);
});
test("correct tag and category filters for different lists", function (assert) { test("correct tag and category filters for different lists", function (assert) {
this.trackingState.trackIncoming("unread"); this.trackingState.trackIncoming("unread");
assert.strictEqual(this.trackingState.filterCategory, undefined); assert.strictEqual(this.trackingState.filterCategory, undefined);