Skip to content

A platform for community discussion. Free, open, simple.

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

Osama Sayegh118ce348f495
diff --git a/app/assets/javascripts/discourse/app/components/count-i18n.js b/app/assets/javascripts/discourse/app/components/count-i18n.js
index 6fa2ca3141a..884d1e06667 100644
--- a/app/assets/javascripts/discourse/app/components/count-i18n.js
+++ b/app/assets/javascripts/discourse/app/components/count-i18n.js
@@ -8,9 +8,14 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
- this.set(
- "i18nCount",
- htmlSafe(I18n.t(this.key + (this.suffix || ""), { count: this.count }))
- );
+
+ let fullKey = this.key + (this.suffix || "");
+ 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 })));
},
});
diff --git a/app/assets/javascripts/discourse/app/models/topic-tracking-state.js b/app/assets/javascripts/discourse/app/models/topic-tracking-state.js
index bd6d49ef8aa..39ea6edda58 100644
--- a/app/assets/javascripts/discourse/app/models/topic-tracking-state.js
+++ b/app/assets/javascripts/discourse/app/models/topic-tracking-state.js
@@ -284,11 +284,12 @@ const TopicTrackingState = EmberObject.extend({
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
- if (
- ["all", "unread", "unseen"].includes(filter) &&
- data.message_type === "unread"
- ) {
+ if (unreadRecipients.includes(filter) && data.message_type === "unread") {
const old = this.findState(data);
// the highest post number is equal to last read post number here
diff --git a/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js b/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js
index 5885f4370c2..3f03c156407 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js
@@ -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) {
this.trackingState.trackIncoming("unread");
assert.strictEqual(this.trackingState.filterCategory, undefined);