A platform for community discussion. Free, open, simple.
UX: Remove redundant unread/new labels for empty topic list (#35350)
Martin Brennan978059e9e0ac
diff --git a/app/assets/javascripts/discourse/app/components/discovery/topics.gjs b/app/assets/javascripts/discourse/app/components/discovery/topics.gjsindex 9dd01c9884c..f4455191eda 100644--- a/app/assets/javascripts/discourse/app/components/discovery/topics.gjs+++ b/app/assets/javascripts/discourse/app/components/discovery/topics.gjs@@ -138,29 +138,42 @@ export default class DiscoveryTopics extends Component {return;}+ const filterSegments = (this.args.model.get("filter") || "").split("/");+ const lastFilterSegment = filterSegments.at(-1);+ const newOrUnreadFilter =+ lastFilterSegment === "new" || lastFilterSegment === "unread";const { category, tag } = this.args;if (category) {+ // We have a different custom display for the empty new + unread filter education.+ if (topicsLength === 0 && newOrUnreadFilter) {+ return;+ }+return i18n("topics.bottom.category", {- category: category.get("name"),+ category: category.name,});} else if (tag) {+ // We have a different custom display for the empty new + unread filter education.+ if (topicsLength === 0 && newOrUnreadFilter) {+ return;+ }+return i18n("topics.bottom.tag", {tag: tag.id,});} else {- const split = (this.args.model.get("filter") || "").split("/");if (topicsLength === 0) {// We have a different custom display for the empty new + unread filter education.- if (split[0] === "new" || split[0] === "unread") {+ if (newOrUnreadFilter) {return;}- return i18n("topics.none." + split[0], {- category: split[1],+ return i18n(`topics.none.${lastFilterSegment}`, {+ category: filterSegments[1],});} else {- return i18n("topics.bottom." + split[0], {- category: split[1],+ return i18n(`topics.bottom.${lastFilterSegment}`, {+ category: filterSegments[1],});}}@@ -174,7 +187,7 @@ export default class DiscoveryTopics extends Component {}const segments = (this.args.model.get("filter") || "").split("/");- const tab = segments[segments.length - 1];+ const tab = segments.at(-1);if (tab === "new" || tab === "unread") {return true;}diff --git a/spec/system/unified_new_topic_list_spec.rb b/spec/system/unified_new_topic_list_spec.rbindex 92dee105f28..535fe26b46f 100644--- a/spec/system/unified_new_topic_list_spec.rb+++ b/spec/system/unified_new_topic_list_spec.rb@@ -220,6 +220,24 @@ describe "Unified new topic list", type: :system doexpect(tabs_toggle.replies_tab).to have_count(1)expect(tabs_toggle.topics_tab).to have_count(1)end++ it "does not show a 'no more topics' footer message that clashes with the empty topic filter" do+ TopicUser.update_last_read(user, new_topic_in_category.id, 1, 1, 1)+ TopicUser.update_last_read(user, new_reply_in_category.id, 2, 1, 1)+ TopicUser.update_last_read(user, old_topic_in_category.id, 2, 1, 1)++ visit("/c/#{category.slug}/#{category.id}/l/new")++ expect(page).not_to have_content(+ I18n.t("js.topics.bottom.category", category: category.name),+ )++ visit("/c/#{category.slug}/#{category.id}/l/unread")++ expect(page).not_to have_content(+ I18n.t("js.topics.bottom.category", category: category.name),+ )+ endendcontext "when the /new topic list is scoped to a tag" do@@ -300,6 +318,20 @@ describe "Unified new topic list", type: :system doexpect(tabs_toggle.replies_tab).to have_count(1)expect(tabs_toggle.topics_tab).to have_count(1)end++ it "does not show a 'no more topics' footer message that clashes with the empty topic filter" do+ TopicUser.update_last_read(user, new_topic_with_tag.id, 1, 1, 1)+ TopicUser.update_last_read(user, new_reply_with_tag.id, 2, 1, 1)+ TopicUser.update_last_read(user, old_topic_with_tag.id, 2, 1, 1)++ visit("/tag/#{tag.name}/l/new")++ expect(page).not_to have_content(I18n.t("js.topics.bottom.tag", tag: tag.name))++ visit("/tag/#{tag.name}/l/unread")++ expect(page).not_to have_content(I18n.t("js.topics.bottom.tag", tag: tag.name))+ endendend