A platform for community discussion. Free, open, simple.
FIX: Regression causing missing chat unread indicators (#36466)
Keegan George44f75d041ebb
diff --git a/app/assets/stylesheets/common/base/sidebar-section-link.scss b/app/assets/stylesheets/common/base/sidebar-section-link.scssindex bfb89483deb..cdccbde294a 100644--- a/app/assets/stylesheets/common/base/sidebar-section-link.scss+++ b/app/assets/stylesheets/common/base/sidebar-section-link.scss@@ -89,16 +89,16 @@@include ellipsis;padding-left: 0.5em;padding-right: 0.1em; // avoids some overflow cropping- text-align: right;color: var(--d-sidebar-link-badge-color);font-size: var(--font-down-2);font-weight: normal;- margin-left: auto;+ flex-shrink: 0;}.sidebar-section-link-suffix {margin-left: 1em;font-size: var(--font-down-4);+ flex-shrink: 0;&.icon {&.urgent svg {@@ -113,6 +113,8 @@.sidebar-section-link-content-text {@include ellipsis;+ min-width: 0;+ flex: 0 1 auto;.user-status-message {vertical-align: -0.125em;diff --git a/frontend/discourse/app/components/sidebar/api-section.gjs b/frontend/discourse/app/components/sidebar/api-section.gjsindex d9d48ee33de..5bf073c64de 100644--- a/frontend/discourse/app/components/sidebar/api-section.gjs+++ b/frontend/discourse/app/components/sidebar/api-section.gjs@@ -56,6 +56,8 @@ const SidebarApiSection = <template>link.contentComponentstatus=link.contentComponentArgs}}+ @suffixComponent={{link.suffixComponent}}+ @suffixArgs={{link.suffixArgs}}@scrollIntoView={{and@scrollActiveLinkIntoView(eq link.name @section.activeLink.name)diff --git a/frontend/discourse/app/components/sidebar/section-link.gjs b/frontend/discourse/app/components/sidebar/section-link.gjsindex 580c6584224..8000f585e77 100644--- a/frontend/discourse/app/components/sidebar/section-link.gjs+++ b/frontend/discourse/app/components/sidebar/section-link.gjs@@ -29,6 +29,14 @@ export function isHex(input) {}}+/**+ * Sidebar section link component.+ *+ * @component SectionLink+ * @param {Component} @contentComponent - Component to render inside the link text span (gets ellipsized)+ * @param {Component} @suffixComponent - Component to render after the link text (stays visible, not ellipsized)+ * @param {Object} @suffixArgs - Arguments to pass to the suffix component+ */export default class SectionLink extends Component {@service currentUser;@@ -201,6 +209,10 @@ export default class SectionLink extends Component {</span>{{/if}}+ {{#if @suffixComponent}}+ <@suffixComponent @suffixArgs={{@suffixArgs}} />+ {{/if}}+{{#if @suffixValue}}<spanclass={{concatClassdiff --git a/frontend/discourse/app/lib/sidebar/base-custom-sidebar-section-link.js b/frontend/discourse/app/lib/sidebar/base-custom-sidebar-section-link.jsindex a044eb76236..2f09adb412d 100644--- a/frontend/discourse/app/lib/sidebar/base-custom-sidebar-section-link.js+++ b/frontend/discourse/app/lib/sidebar/base-custom-sidebar-section-link.js@@ -65,6 +65,16 @@ export default class BaseCustomSidebarSectionLink {*/get contentCSSClass() {}+ /**+ * @returns {Component} Component to render inside the link text span (gets ellipsized with text)+ */+ get contentComponent() {}++ /**+ * @returns {Object} Arguments to pass to the content component+ */+ get contentComponentArgs() {}+/*** @returns {string} Prefix type for the link. Accepted value: icon, image, text*/@@ -105,6 +115,16 @@ export default class BaseCustomSidebarSectionLink {*/get suffixCSSClass() {}+ /**+ * @returns {Component} Component to render as suffix (outside text span, not ellipsized)+ */+ get suffixComponent() {}++ /**+ * @returns {Object} Arguments to pass to the suffix component+ */+ get suffixArgs() {}+/*** @returns {string} Type of the hover button. Accepted value: icon*/diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-indicators.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-indicators.gjsindex 624225938b9..6b816cf0936 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-indicators.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-indicators.gjs@@ -6,13 +6,13 @@ import icon from "discourse/helpers/d-icon";* Displays unread indicators and user status for chat channels in the sidebar.** @component ChatSidebarIndicators- * @param {Object} @status - Channel status object containing unread counts and user status- * @param {number} @status.unreadCount - Number of unread messages- * @param {number} @status.unreadThreadsCount - Number of unread threads- * @param {number} @status.mentionCount - Number of unread mentions- * @param {number} @status.watchedThreadsUnreadCount - Number of unread watched threads- * @param {boolean} @status.isDirectMessageChannel - Whether this is a DM channel- * @param {Object} @status.userStatus - User status object for DM channels+ * @param {Object} @suffixArgs - Arguments object when used as @suffixComponent+ * @param {number} @suffixArgs.unreadCount - Number of unread messages+ * @param {number} @suffixArgs.unreadThreadsCount - Number of unread threads+ * @param {number} @suffixArgs.mentionCount - Number of unread mentions+ * @param {number} @suffixArgs.watchedThreadsUnreadCount - Number of unread watched threads+ * @param {boolean} @suffixArgs.isDirectMessageChannel - Whether this is a DM channel+ * @param {Object} @suffixArgs.userStatus - User status object for DM channels*/export default class ChatSidebarIndicators extends Component {/**@@ -22,10 +22,10 @@ export default class ChatSidebarIndicators extends Component {*/get hasUnread() {return (- this.args.status?.unreadCount > 0 ||- this.args.status?.unreadThreadsCount > 0 ||- this.args.status?.mentionCount > 0 ||- this.args.status?.watchedThreadsUnreadCount > 0+ this.args.suffixArgs?.unreadCount > 0 ||+ this.args.suffixArgs?.unreadThreadsCount > 0 ||+ this.args.suffixArgs?.mentionCount > 0 ||+ this.args.suffixArgs?.watchedThreadsUnreadCount > 0);}@@ -38,13 +38,13 @@ export default class ChatSidebarIndicators extends Component {*/get urgencyClass() {const hasUrgent =- this.args.status?.mentionCount > 0 ||- this.args.status?.watchedThreadsUnreadCount > 0;+ this.args.suffixArgs?.mentionCount > 0 ||+ this.args.suffixArgs?.watchedThreadsUnreadCount > 0;// For DMs, treat all unreads as urgentconst hasUnreadDM =- this.args.status?.isDirectMessageChannel &&- this.args.status?.unreadCount > 0;+ this.args.suffixArgs?.isDirectMessageChannel &&+ this.args.suffixArgs?.unreadCount > 0;if (hasUrgent || hasUnreadDM) {return "urgent";@@ -53,8 +53,8 @@ export default class ChatSidebarIndicators extends Component {}<template>- {{#if @status.userStatus}}- <UserStatusMessage @status={{@status.userStatus}} />+ {{#if @suffixArgs.userStatus}}+ <UserStatusMessage @status={{@suffixArgs.userStatus}} />{{/if}}{{#if this.hasUnread}}<spandiff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.jsindex ee5e071b275..a28bde7a5f1 100644--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js@@ -189,11 +189,11 @@ function createChannelLink(BaseCustomSidebarSectionLink, options = {}) {return "";}- get contentComponent() {+ get suffixComponent() {return ChatSidebarIndicators;}- get contentComponentArgs() {+ get suffixArgs() {if (this.isDM) {return {userStatus: this.isOneOnOneDM@@ -529,11 +529,11 @@ export default {return this.channel.chatable.read_restricted ? "lock" : "";}- get contentComponent() {+ get suffixComponent() {return ChatSidebarIndicators;}- get contentComponentArgs() {+ get suffixArgs() {return {unreadCount: this.channel.tracking.unreadCount,// We want to do this so we don't show a blue dot if the user is inside@@ -680,11 +680,11 @@ export default {return this.channel.chatable.users.length === 1;}- get contentComponent() {+ get suffixComponent() {return ChatSidebarIndicators;}- get contentComponentArgs() {+ get suffixArgs() {return {userStatus: this.oneOnOneMessage? this.channel.chatable.users[0].get("status")diff --git a/plugins/chat/assets/stylesheets/common/core-extensions.scss b/plugins/chat/assets/stylesheets/common/core-extensions.scssindex 8f029ecf885..977fc45db7e 100644--- a/plugins/chat/assets/stylesheets/common/core-extensions.scss+++ b/plugins/chat/assets/stylesheets/common/core-extensions.scss@@ -35,6 +35,7 @@display: inline-flex;align-items: center;margin-left: 0.5em;+ flex-shrink: 0;svg {font-size: var(--font-down-2);diff --git a/plugins/chat/test/javascripts/components/chat-sidebar-indicators-test.gjs b/plugins/chat/test/javascripts/components/chat-sidebar-indicators-test.gjsindex fca85f00fa9..3df7f809a3f 100644--- a/plugins/chat/test/javascripts/components/chat-sidebar-indicators-test.gjs+++ b/plugins/chat/test/javascripts/components/chat-sidebar-indicators-test.gjs@@ -12,7 +12,7 @@ module(const status = { unreadCount: 1 };await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").exists();@@ -22,7 +22,7 @@ module(const status = { unreadThreadsCount: 1 };await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").exists();@@ -32,7 +32,7 @@ module(const status = { mentionCount: 1 };await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").exists();@@ -43,7 +43,7 @@ module(const status = { watchedThreadsUnreadCount: 1 };await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").exists();@@ -59,7 +59,7 @@ module(};await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").doesNotExist();@@ -72,7 +72,7 @@ module(};await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").hasClass("urgent");@@ -85,7 +85,7 @@ module(};await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").hasClass("unread");@@ -101,7 +101,7 @@ module(};await render(- <template><ChatSidebarIndicators @status={{status}} /></template>+ <template><ChatSidebarIndicators @suffixArgs={{status}} /></template>);assert.dom(".sidebar-section-link-content-badge").exists();