FIX: chat channel row indicator should only show urgent count (#25458)

Correctly shows the number of urgent notifications in channel list, rather than showing all new notifications as urgent.
This commit is contained in:
David Battersby 2024-01-31 16:47:54 +08:00 committed by GitHub
parent a695d85cbd
commit e944468162
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 9 deletions

View File

@ -19,7 +19,7 @@ export default class ChatChannelUnreadIndicator extends Component {
}
get unreadCount() {
if (this.#onlyMentions() && this.#hasChannelMentions()) {
if (this.#hasChannelMentions()) {
return this.args.channel.tracking.mentionCount;
}
return this.args.channel.tracking.unreadCount;
@ -34,13 +34,6 @@ export default class ChatChannelUnreadIndicator extends Component {
);
}
get showUnreadCount() {
if (this.#onlyMentions()) {
return this.#hasChannelMentions();
}
return this.args.channel.isDirectMessageChannel || this.isUrgent;
}
#hasChannelMentions() {
return this.args.channel.tracking.mentionCount > 0;
}
@ -58,7 +51,7 @@ export default class ChatChannelUnreadIndicator extends Component {
}}
>
<div class="chat-channel-unread-indicator__number">{{#if
this.showUnreadCount
this.isUrgent
}}{{this.unreadCount}}{{else}}&nbsp;{{/if}}</div>
</div>
{{/if}}

View File

@ -104,6 +104,26 @@ RSpec.describe "Message notifications - mobile", type: :system, mobile: true do
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator")
expect(channel_index_page).to have_unread_channel(channel_1, count: 1)
end
it "shows correct count when there are multiple messages but only 1 is urgent" do
Jobs.run_immediately!
visit("/chat/channels")
create_message(
channel_1,
user: user_1,
text: "Are you busy @#{current_user.username}?",
)
3.times { create_message(channel_1, user: user_1) }
expect(page).to have_css(
".chat-header-icon .chat-channel-unread-indicator",
text: "1",
)
expect(channel_index_page).to have_unread_channel(channel_1, count: 1)
end
end
end
end