FIX: Navigating out of thread shows other unread threads (#24693)

* FIX: Navigating out of thread shows other unread threads

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
Jan Cernik 2023-12-11 09:44:50 -03:00 committed by GitHub
parent 2eed8753fb
commit cf9bef0499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -40,6 +40,10 @@ export default class ChatThreadHeader extends Component {
route = "chat.channel.threads";
title = I18n.t("chat.return_to_threads_list");
models = this.args.channel.routeModels;
} else if (!this.currentUser.isInDoNotDisturb() && this.unreadCount > 0) {
route = "chat.channel.threads";
title = I18n.t("chat.return_to_threads_list");
models = this.args.channel.routeModels;
} else if (prevPage === "chat.threads") {
route = "chat.threads";
title = I18n.t("chat.my_threads.title");
@ -76,6 +80,10 @@ export default class ChatThreadHeader extends Component {
return this.args.thread?.title ?? I18n.t("chat.thread.label");
}
get unreadCount() {
return this.args.channel.threadsManager.unreadThreadCount;
}
@action
openThreadSettings() {
this.modal.show(ChatModalThreadSettings, { model: this.args.thread });

View File

@ -161,6 +161,26 @@ RSpec.describe "Navigation", type: :system do
expect(page).to have_current_path("#{category_channel.relative_url}/t")
expect(thread_list_page).to have_loaded
end
context "when there are unread threads" do
fab!(:thread_2) { Fabricate(:chat_thread, channel: category_channel, use_service: true) }
before { Fabricate(:chat_message, thread: thread_2, use_service: true) }
it "goes back to the thread list when clicking the back button", mobile: true do
chat_page.visit_channel(category_channel)
channel_page.message_thread_indicator(thread.original_message).click
thread_page.send_message
thread_page.back
channel_page.message_thread_indicator(thread_2.original_message).click
Fabricate(:chat_message, thread: thread, use_service: true)
expect(thread_page).to have_unread_list_indicator(count: 1)
expect(thread_page).to have_back_link_to_thread_list(category_channel)
thread_page.back
expect(page).to have_current_path("#{category_channel.relative_url}/t")
end
end
end
end