mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 19:44:36 +08:00
FIX: chat activity indicator wasn't working for threads
When a user had the chat option "Show activity indicator in header" set to "all new messages", and they would get a reply to a thread they're part of, the chat icon in the header would not show the unread bubble indicator. In order to fix this, the `ChatHeaderIconUnreadIndicator` component will now `showUnreadIndicator` whenever there is either one unread public channel or there are unread threads. I only added a system spec for this very specific path because I don't want to slow down the whole suite to test for all the various combination of the `chat_header_indicator_preference` values. Internal ref - t/128874
This commit is contained in:
parent
24230e7461
commit
0012d9626f
|
@ -13,6 +13,10 @@ module Chat
|
||||||
enum :desktop_notification_level, NOTIFICATION_LEVELS, prefix: :desktop_notifications
|
enum :desktop_notification_level, NOTIFICATION_LEVELS, prefix: :desktop_notifications
|
||||||
enum :mobile_notification_level, NOTIFICATION_LEVELS, prefix: :mobile_notifications
|
enum :mobile_notification_level, NOTIFICATION_LEVELS, prefix: :mobile_notifications
|
||||||
enum :join_mode, { manual: 0, automatic: 1 }
|
enum :join_mode, { manual: 0, automatic: 1 }
|
||||||
|
|
||||||
|
def mark_read!(new_last_read_id = nil)
|
||||||
|
update!(last_read_message_id: new_last_read_id || chat_channel.last_message_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,12 @@ export default class ChatHeaderIconUnreadIndicator extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get hasUnreads() {
|
||||||
|
return (
|
||||||
|
this.unreadCount > 0 || this.chatTrackingStateManager.hasUnreadThreads
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
get indicatorPreference() {
|
get indicatorPreference() {
|
||||||
return (
|
return (
|
||||||
this.args.indicatorPreference ||
|
this.args.indicatorPreference ||
|
||||||
|
@ -57,7 +63,7 @@ export default class ChatHeaderIconUnreadIndicator extends Component {
|
||||||
|
|
||||||
get showUnreadIndicator() {
|
get showUnreadIndicator() {
|
||||||
return (
|
return (
|
||||||
this.unreadCount > 0 &&
|
this.hasUnreads &&
|
||||||
this.#hasAnyIndicatorPreference([HEADER_INDICATOR_PREFERENCE_ALL_NEW])
|
this.#hasAnyIndicatorPreference([HEADER_INDICATOR_PREFERENCE_ALL_NEW])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,21 @@ RSpec.describe "Message notifications - with sidebar", type: :system do
|
||||||
|
|
||||||
let!(:chat_page) { PageObjects::Pages::Chat.new }
|
let!(:chat_page) { PageObjects::Pages::Chat.new }
|
||||||
let!(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
let!(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
||||||
|
let!(:thread_page) { PageObjects::Pages::ChatThread.new }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.navigation_menu = "sidebar"
|
SiteSetting.navigation_menu = "sidebar"
|
||||||
chat_system_bootstrap
|
chat_system_bootstrap
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_message(text: nil, channel:, creator: Fabricate(:user))
|
def create_message(text: nil, channel: nil, thread: nil, creator: Fabricate(:user))
|
||||||
Fabricate(:chat_message_with_service, chat_channel: channel, message: text, user: creator)
|
Fabricate(
|
||||||
|
:chat_message_with_service,
|
||||||
|
chat_channel: channel,
|
||||||
|
thread: thread,
|
||||||
|
message: text,
|
||||||
|
user: creator,
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "as a user" do
|
context "as a user" do
|
||||||
|
@ -225,6 +232,40 @@ RSpec.describe "Message notifications - with sidebar", type: :system do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a thread" do
|
||||||
|
fab!(:channel) { Fabricate(:category_channel, threading_enabled: true) }
|
||||||
|
fab!(:other_user) { Fabricate(:user) }
|
||||||
|
fab!(:thread) do
|
||||||
|
chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
channel.membership_for(current_user).mark_read!
|
||||||
|
thread.membership_for(current_user).mark_read!
|
||||||
|
|
||||||
|
visit("/")
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when chat_header_indicator_preference is 'all_new'" do
|
||||||
|
before do
|
||||||
|
current_user.user_option.update!(
|
||||||
|
chat_header_indicator_preference:
|
||||||
|
UserOption.chat_header_indicator_preferences[:all_new],
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when a reply is created" do
|
||||||
|
it "shows the unread indicator in the header" do
|
||||||
|
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
|
||||||
|
|
||||||
|
create_message(thread: thread, creator: other_user)
|
||||||
|
|
||||||
|
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,10 +6,8 @@ describe "Thread indicator for chat messages", type: :system do
|
||||||
|
|
||||||
let(:chat_page) { PageObjects::Pages::Chat.new }
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||||
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
||||||
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
|
||||||
let(:side_panel) { PageObjects::Pages::ChatSidePanel.new }
|
let(:side_panel) { PageObjects::Pages::ChatSidePanel.new }
|
||||||
let(:open_thread) { PageObjects::Pages::ChatThread.new }
|
let(:open_thread) { PageObjects::Pages::ChatThread.new }
|
||||||
let(:chat_drawer_page) { PageObjects::Pages::ChatDrawer.new }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
chat_system_bootstrap(current_user, [channel])
|
chat_system_bootstrap(current_user, [channel])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user