From 83a4465da6fe87e599f36ab077f237307b864693 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Wed, 1 Jul 2026 15:55:23 +1000 Subject: [PATCH] UX: Show split new/unread count based on unified new for the site Show a "Topics (N)" and "Replies (N)" count instead of new/unread counts when unified new is enabled for a site, which also takes the user to the /new?subset=X routes for each link. Needs https://github.com/discourse/discourse/pull/41316 to work --- js/locale/en.json | 2 ++ js/screens/HomeScreen.js | 9 +++++++-- js/screens/HomeScreenComponents/SiteRow.js | 14 ++++++++++---- js/site.js | 2 ++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/js/locale/en.json b/js/locale/en.json index e7e92390..e22cbcf0 100644 --- a/js/locale/en.json +++ b/js/locale/en.json @@ -42,6 +42,7 @@ "chat_group_mention": "%{username} mentioned %{group_name} in chat", "new_features": "New features available!", "new_with_count": "new (%{count})", + "new_with_count_unified": "Topics (%{count})", "new": "New", "no_notifications": "No notifications", "no_replies": "No replies", @@ -52,6 +53,7 @@ "switch_dark": "Use dark theme", "term_exists": "%{term} already exists", "unread_with_count": "unread (%{count})", + "unread_with_count_unified": "Replies (%{count})", "term_placeholder": "Search or enter a community URL", "term_placeholder_single_site": "Enter the community URL", "please_wait": "Please wait...", diff --git a/js/screens/HomeScreen.js b/js/screens/HomeScreen.js index da2c7a58..133e7a0c 100644 --- a/js/screens/HomeScreen.js +++ b/js/screens/HomeScreen.js @@ -59,12 +59,17 @@ class HomeScreen extends React.Component { `${site.url}/session/otp/${site.oneTimePassword}`, ); } else { + // Use & when the endpoint already carries a query string (eg + // /new?subset=topics) so we don't produce an invalid double-? URL. + const separator = endpoint.includes('?') ? '&' : '?'; if (Platform.OS === 'ios') { const params = await this._siteManager.generateURLParams(site); - this.props.screenProps.openUrl(`${site.url}${endpoint}?${params}`); + this.props.screenProps.openUrl( + `${site.url}${endpoint}${separator}${params}`, + ); } else { this.props.screenProps.openUrl( - `${site.url}${endpoint}?discourse_app=1`, + `${site.url}${endpoint}${separator}discourse_app=1`, ); } } diff --git a/js/screens/HomeScreenComponents/SiteRow.js b/js/screens/HomeScreenComponents/SiteRow.js index 8e3c0a6d..055e9d88 100644 --- a/js/screens/HomeScreenComponents/SiteRow.js +++ b/js/screens/HomeScreenComponents/SiteRow.js @@ -127,14 +127,20 @@ export default function SiteRow(props) { if (props.site.authToken) { if (props.site.totalNew > 0) { shortcuts.new = { - link: '/new', - text: i18n.t('new_with_count', { count: props.site.totalNew }), + link: props.site.usingUnifiedNew ? '/new?subset=topics' : '/new', + text: props.site.usingUnifiedNew + ? i18n.t('new_with_count_unified', { count: props.site.totalNew }) + : i18n.t('new_with_count', { count: props.site.totalNew }), }; } if (props.site.totalUnread > 0) { shortcuts.unread = { - link: '/unread', - text: i18n.t('unread_with_count', { count: props.site.totalUnread }), + link: props.site.usingUnifiedNew ? '/new?subset=replies' : '/unread', + text: props.site.usingUnifiedNew + ? i18n.t('unread_with_count_unified', { + count: props.site.totalUnread, + }) + : i18n.t('unread_with_count', { count: props.site.totalUnread }), }; } } diff --git a/js/site.js b/js/site.js index 662e47a2..24db5027 100644 --- a/js/site.js +++ b/js/site.js @@ -275,6 +275,8 @@ class Site { this.chatNotifications = totals.chat_notifications || 0; this.totalUnread = totals?.topic_tracking.unread || 0; this.totalNew = totals?.topic_tracking.new || 0; + this.usingUnifiedNew = + totals?.topic_tracking.unified_new_enabled ?? false; this.username = totals.username; if (totals.group_inboxes) { this.groupInboxes = totals.group_inboxes;