A platform for community discussion. Free, open, simple.
FIX: do not refresh when accessing loaded reply (#20526)
Joffrey JAFFEUX9e49abc0b9c9
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.jsindex 9bc16a5736d..ab25fc88b67 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js@@ -103,6 +103,10 @@ export default class ChatLivePane extends Component {@actionupdateChannel() {+ // Technically we could keep messages to avoid re-fetching them, but+ // it's not worth the complexity for now+ this.args.channel?.clearMessages();+if (this._loadedChannelId !== this.args.channel?.id) {this._unsubscribeToUpdates(this._loadedChannelId);this.selectingMessages = false;diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel.jsindex 34ca9343de6..69ea1c3b3f8 100644--- a/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js+++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js@@ -10,10 +10,6 @@ export default class ChatChannelRoute extends DiscourseRoute {@actionwillTransition(transition) {- // Technically we could keep messages to avoid re-fetching them, but- // it's not worth the complexity for now- this.chat.activeChannel?.clearMessages();-this.chat.activeChannel.activeThread = null;this.chatStateManager.closeSidePanel();diff --git a/plugins/chat/spec/system/reply_indicator_spec.rb b/plugins/chat/spec/system/reply_indicator_spec.rbnew file mode 100644index 00000000000..bae2eac3100--- /dev/null+++ b/plugins/chat/spec/system/reply_indicator_spec.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++RSpec.describe "Reply indicator", type: :system, js: true do+ let(:chat_page) { PageObjects::Pages::Chat.new }+ let(:channel_page) { PageObjects::Pages::ChatChannel.new }++ fab!(:channel_1) { Fabricate(:category_channel) }+ fab!(:current_user) { Fabricate(:admin) }++ before do+ chat_system_bootstrap+ channel_1.add(current_user)+ sign_in(current_user)+ end++ context "when clicking on a reply indicator of a loaded message" do+ fab!(:replied_to_message) do+ Fabricate(:chat_message, chat_channel: channel_1, created_at: 2.hours.ago)+ end+ fab!(:reply) do+ Fabricate(+ :chat_message,+ chat_channel: channel_1,+ in_reply_to: replied_to_message,+ created_at: 1.minute.ago,+ )+ end++ before do+ 10.times { Fabricate(:chat_message, chat_channel: channel_1, created_at: 1.hour.ago) }+ end++ it "highlights the message without refreshing the pane" do+ chat_page.visit_channel(channel_1)++ find("[data-id='#{reply.id}'] .chat-reply").click++ expect(page).to have_no_selector(".chat-skeleton")+ expect(page).to have_selector("[data-id='#{replied_to_message.id}'].highlighted", wait: 0.1)+ end+ end+end