diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-name/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-name/index.gjs
index 566da4c06cd..f42ee6101dd 100644
--- a/plugins/chat/assets/javascripts/discourse/components/channel-name/index.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/channel-name/index.gjs
@@ -5,10 +5,15 @@ import { htmlSafe } from "@ember/template";
import PluginOutlet from "discourse/components/plugin-outlet";
import UserStatusMessage from "discourse/components/user-status-message";
import replaceEmoji from "discourse/helpers/replace-emoji";
+import ChatChannelUnreadIndicator from "../chat-channel-unread-indicator";
export default class ChatChannelName extends Component {
@service currentUser;
+ get unreadIndicator() {
+ return this.args.unreadIndicator ?? false;
+ }
+
get firstUser() {
return this.args.channel.chatable.users[0];
}
@@ -37,27 +42,43 @@ export default class ChatChannelName extends Component {
}
get showUserStatus() {
+ if (!this.args.channel.isDirectMessageChannel) {
+ return false;
+ }
return !!(this.users.length === 1 && this.users[0].status);
}
+ get channelTitle() {
+ if (this.args.channel.isDirectMessageChannel) {
+ return this.groupDirectMessage
+ ? this.groupsDirectMessageTitle
+ : this.firstUser.username;
+ }
+ return this.args.channel.title;
+ }
+
+ get showPluginOutlet() {
+ return this.args.channel.isDirectMessageChannel && !this.groupDirectMessage;
+ }
+
- {{#if @channel.isDirectMessageChannel}}
- {{#if this.groupDirectMessage}}
-
- {{this.groupsDirectMessageTitle}}
-
- {{else}}
-
- {{this.firstUser.username}}
-
- {{#if this.showUserStatus}}
-
- {{/if}}
+
+ {{replaceEmoji this.channelTitle}}
+
+ {{#if this.unreadIndicator}}
+
+ {{/if}}
+
+ {{#if this.showUserStatus}}
+
+ {{/if}}
+
+ {{#if this.showPluginOutlet}}
{{/if}}
- {{else if @channel.isCategoryChannel}}
-
- {{replaceEmoji @channel.title}}
-
{{#if (has-block)}}
{{yield}}
{{/if}}
- {{/if}}
+
}
diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs
index 2ae556abff1..a3364699d5c 100644
--- a/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/channel-title/index.gjs
@@ -3,7 +3,7 @@ import ChannelIcon from "discourse/plugins/chat/discourse/components/channel-ico
import ChannelName from "discourse/plugins/chat/discourse/components/channel-name";
const ChatChannelTitle =
-
+ {{#if @isUnread}}
+
+ {{/if}}
+
{{#if (has-block)}}
{{yield}}
{{/if}}
-
+
;
export default ChatChannelTitle;
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs
index b2ce7799d42..069440d8934 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs
@@ -1,12 +1,7 @@
import Component from "@glimmer/component";
import I18n from "discourse-i18n";
-import ChatChannelUnreadIndicator from "./chat-channel-unread-indicator";
export default class ChatChannelMetadata extends Component {
- get unreadIndicator() {
- return this.args.unreadIndicator ?? false;
- }
-
get lastMessageFormattedDate() {
return moment(this.args.channel.lastMessage.createdAt).calendar(null, {
sameDay: "LT",
@@ -23,10 +18,6 @@ export default class ChatChannelMetadata extends Component {
{{this.lastMessageFormattedDate}}
{{/if}}
-
- {{#if this.unreadIndicator}}
-
- {{/if}}
}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.gjs
index 5bb42ef778c..08ac0e753e0 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-row.gjs
@@ -196,11 +196,8 @@ export default class ChatChannelRow extends Component {
>
-
-
+
+
{{#if this.shouldRenderLastMessage}}
{{replaceEmoji (htmlSafe @channel.lastMessage.excerpt)}}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/channel.gjs
index eb78c9e9ffe..94b36fa4db9 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/channel.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/message-creator/channel.gjs
@@ -1,7 +1,6 @@
import Component from "@glimmer/component";
import { service } from "@ember/service";
import { gt, not } from "truth-helpers";
-import concatClass from "discourse/helpers/concat-class";
import ChannelTitle from "discourse/plugins/chat/discourse/components/channel-title";
export default class Channel extends Component {
@@ -22,14 +21,11 @@ export default class Channel extends Component {
class="chat-message-creator__chatable -category-channel"
data-disabled={{not @item.enabled}}
>
-
-
- {{#if (gt @item.tracking.unreadCount 0)}}
-
-
- {{/if}}
+
}
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js
index b3cea54723c..341fc91b159 100644
--- a/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js
+++ b/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js
@@ -20,7 +20,6 @@ export default class ChatChannelsManager extends Service {
@service chatStateManager;
@service currentUser;
@service router;
- @service site;
@service siteSettings;
@tracked _cached = new TrackedObject();
@@ -130,11 +129,7 @@ export default class ChatChannelsManager extends Service {
channel.isCategoryChannel && channel.currentUserMembership.following
);
- if (this.site.mobileView) {
- return this.#sortChannelsByActivity(channels);
- } else {
- return channels.sort((a, b) => a?.slug?.localeCompare?.(b?.slug));
- }
+ return this.#sortChannelsByActivity(channels);
}
@cached
diff --git a/plugins/chat/assets/stylesheets/common/chat-channel-name.scss b/plugins/chat/assets/stylesheets/common/chat-channel-name.scss
index 23651a2c0f1..a329012d074 100644
--- a/plugins/chat/assets/stylesheets/common/chat-channel-name.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-channel-name.scss
@@ -7,6 +7,8 @@
}
&__label {
+ display: flex;
+ align-items: center;
white-space: nowrap;
}
@@ -15,4 +17,21 @@
width: 1em;
vertical-align: baseline;
}
+
+ .chat-channel-unread-indicator {
+ @include chat-unread-indicator;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 8px;
+ height: 8px;
+ margin-left: 0.75em;
+
+ &.-urgent {
+ width: auto;
+ height: auto;
+ min-width: 0.6em;
+ padding: 0.3em 0.5em;
+ }
+ }
}
diff --git a/plugins/chat/assets/stylesheets/common/chat-channel-row.scss b/plugins/chat/assets/stylesheets/common/chat-channel-row.scss
index 8cf86fe5aa2..6af3a5d3df9 100644
--- a/plugins/chat/assets/stylesheets/common/chat-channel-row.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-channel-row.scss
@@ -90,22 +90,6 @@
align-items: flex-end;
flex-direction: column;
margin-left: 0.5em;
-
- .chat-channel-unread-indicator {
- @include chat-unread-indicator;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 8px;
- height: 8px;
-
- &.-urgent {
- width: auto;
- height: auto;
- min-width: 0.6em;
- padding: 0.3em 0.5em;
- }
- }
}
&__metadata-date {
diff --git a/plugins/chat/assets/stylesheets/common/chat-message-creator.scss b/plugins/chat/assets/stylesheets/common/chat-message-creator.scss
index 0a8ff4ec031..478bb05231c 100644
--- a/plugins/chat/assets/stylesheets/common/chat-message-creator.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-message-creator.scss
@@ -267,11 +267,14 @@
}
.unread-indicator {
- margin-left: 0.5rem;
width: 8px;
height: 8px;
background: var(--tertiary);
border-radius: 100%;
+
+ &.-urgent {
+ background: var(--success);
+ }
}
}
diff --git a/plugins/chat/spec/system/channel_settings_page_spec.rb b/plugins/chat/spec/system/channel_settings_page_spec.rb
index 97b1930694f..18df1356a58 100644
--- a/plugins/chat/spec/system/channel_settings_page_spec.rb
+++ b/plugins/chat/spec/system/channel_settings_page_spec.rb
@@ -100,7 +100,7 @@ RSpec.describe "Channel - Info - Settings page", type: :system do
expect(page.find(".c-channel-settings__name")["innerHTML"].strip).to eq(
"<script>alert('hello')</script>",
)
- expect(page.find(".chat-channel-name__label")["innerHTML"].strip).to eq(
+ expect(page.find(".chat-channel-name__label")["innerHTML"].strip).to include(
"<script>alert('hello')</script>",
)
end
diff --git a/plugins/chat/test/javascripts/components/channel-name-test.gjs b/plugins/chat/test/javascripts/components/channel-name-test.gjs
index 35e4e7fd49d..de581224506 100644
--- a/plugins/chat/test/javascripts/components/channel-name-test.gjs
+++ b/plugins/chat/test/javascripts/components/channel-name-test.gjs
@@ -66,4 +66,23 @@ module("Discourse Chat | Component |
", function (hooks) {
users.mapBy("username").join(", ")
);
});
+
+ test("unreadIndicator", async function (assert) {
+ const channel = new ChatFabricators(getOwner(this)).directMessageChannel();
+ channel.tracking.unreadCount = 1;
+
+ let unreadIndicator = true;
+ await render(
+
+ );
+
+ assert.true(exists(".chat-channel-unread-indicator"));
+
+ unreadIndicator = false;
+ await render(
+
+ );
+
+ assert.false(exists(".chat-channel-unread-indicator"));
+ });
});
diff --git a/plugins/chat/test/javascripts/components/chat-channel-metadata-test.js b/plugins/chat/test/javascripts/components/chat-channel-metadata-test.js
index 15db0d1a458..063ce399806 100644
--- a/plugins/chat/test/javascripts/components/chat-channel-metadata-test.js
+++ b/plugins/chat/test/javascripts/components/chat-channel-metadata-test.js
@@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-import { exists } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | chat-channel-metadata", function (hooks) {
@@ -29,23 +28,4 @@ module("Discourse Chat | Component | chat-channel-metadata", function (hooks) {
.dom(".chat-channel__metadata-date")
.hasText(lastMessageSentAt.format("LT"));
});
-
- test("unreadIndicator", async function (assert) {
- this.channel = new ChatFabricators(getOwner(this)).directMessageChannel();
- this.channel.tracking.unreadCount = 1;
-
- this.unreadIndicator = true;
- await render(
- hbs`
`
- );
-
- assert.true(exists(".chat-channel-unread-indicator"));
-
- this.unreadIndicator = false;
- await render(
- hbs`
`
- );
-
- assert.false(exists(".chat-channel-unread-indicator"));
- });
});