From 1a1d1424edcc417d976ac2dacd0fb79b34a090a5 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 14 Nov 2022 08:15:02 +0100 Subject: [PATCH 001/195] FIX: only checks for full page instead of preference (#18998) Checking for preference is unsure when in standalone chat app (eg: electron app), this is much more resilient and simple. --- .../templates/components/chat-message-actions-desktop.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chat/assets/javascripts/discourse/templates/components/chat-message-actions-desktop.hbs b/plugins/chat/assets/javascripts/discourse/templates/components/chat-message-actions-desktop.hbs index 30e1bb65a0..1380f497db 100644 --- a/plugins/chat/assets/javascripts/discourse/templates/components/chat-message-actions-desktop.hbs +++ b/plugins/chat/assets/javascripts/discourse/templates/components/chat-message-actions-desktop.hbs @@ -1,6 +1,6 @@
- {{#if this.chatStateManager.isFullPagePreferred}} + {{#if this.chatStateManager.isFullPage}} {{#each this.emojiReactions as |reaction|}} {{/each}} From 27c15bfd53607883d4e0bdac1f7d3f54268e4fa2 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 14 Nov 2022 08:15:20 +0100 Subject: [PATCH 002/195] FIX: ensures composer is focused after edit (#18999) - afterRender is not needed as it's already done in the `chat:focus-composer` event - removes `focusComposer` function which is duplicating logic --- .../discourse/components/chat-live-pane.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js index c23974fa4e..54fd768d2d 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js @@ -246,7 +246,7 @@ export default Component.extend({ this.highlightOrFetchMessage(this.targetMessageId); } - this.focusComposer(); + this._focusComposer(); }) .catch(this._handleErrors) .finally(() => { @@ -1165,6 +1165,7 @@ export default Component.extend({ } if (lastUserMessage) { this.set("editingMessage", lastUserMessage); + this._focusComposer(); } }, @@ -1395,21 +1396,6 @@ export default Component.extend({ return this._fetchAndScrollToLatest(); }, - focusComposer() { - if ( - this._selfDeleted || - this.site.mobileView || - this.chatChannel?.isDraft - ) { - return; - } - - schedule("afterRender", () => { - document.querySelector(".chat-composer-input")?.focus(); - }); - }, - - @afterRender _focusComposer() { this.appEvents.trigger("chat:focus-composer"); }, From 895898b363df8dbd060345f384de04734c2410ce Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 14 Nov 2022 08:16:09 +0100 Subject: [PATCH 003/195] FIX: correctly opens drawer to message id when given (#18994) --- .../discourse/components/topic-chat-float.js | 4 +-- plugins/chat/spec/system/navigation_spec.rb | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/topic-chat-float.js b/plugins/chat/assets/javascripts/discourse/components/topic-chat-float.js index d13ccf1eef..7df6d32ec4 100644 --- a/plugins/chat/assets/javascripts/discourse/components/topic-chat-float.js +++ b/plugins/chat/assets/javascripts/discourse/components/topic-chat-float.js @@ -203,6 +203,7 @@ export default Component.extend({ @action openURL(URL = null) { + this.chat.setActiveChannel(null); this.set("hidden", false); this.set("expanded", true); @@ -214,12 +215,10 @@ export default Component.extend({ switch (route.name) { case "chat": - this.chat.setActiveChannel(null); this.set("view", LIST_VIEW); this.appEvents.trigger("chat:float-toggled", false); return; case "chat.draft-channel": - this.chat.setActiveChannel(null); this.set("view", DRAFT_CHANNEL_VIEW); this.appEvents.trigger("chat:float-toggled", false); return; @@ -227,6 +226,7 @@ export default Component.extend({ return this.chat .getChannelBy("id", route.params.channelId) .then((channel) => { + this.chat.set("messageId", route.queryParams.messageId); this.chat.setActiveChannel(channel); this.set("view", CHAT_VIEW); this.appEvents.trigger("chat:float-toggled", false); diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rb index 59f239cac6..3c48cb2620 100644 --- a/plugins/chat/spec/system/navigation_spec.rb +++ b/plugins/chat/spec/system/navigation_spec.rb @@ -99,6 +99,33 @@ RSpec.describe "Navigation", type: :system, js: true do end end + context "when opening full page with a link containing a message id" do + it "highlights correct message" do + visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}?messageId=#{message.id}") + + expect(page).to have_css( + ".full-page-chat .chat-message-container.highlighted[data-id='#{message.id}']", + ) + end + end + + context "when opening drawer with a link containing a message id" do + it "highlights correct message" do + Fabricate( + :post, + topic: topic, + raw: + "foo", + ) + visit("/t/-/#{topic.id}") + find("a", text: "foo").click + + expect(page).to have_css( + ".topic-chat-container.expanded.visible .chat-message-container.highlighted[data-id='#{message.id}']", + ) + end + end + context "when sidebar is enabled" do before do SiteSetting.enable_experimental_sidebar_hamburger = true From 3d5753c42b8b045eb2bfdf6d41c9dcb12cad32f1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Mon, 14 Nov 2022 20:36:46 +1100 Subject: [PATCH 004/195] FIX: Allow sidebar links to register didInsert actions (#19010) Previously `this.chatService.appEvents.on( "chat:user-tracking-state-changed"...)` was registered on constructor and disabled on `willDestroy`. Constructor is evaluated only once, so when the section was collapsed and collapsed then the events were not observed anymore. didInsert allows evaluating code each time a component is rendered. --- .../app/components/sidebar/section-link.hbs | 2 +- .../app/components/sidebar/section-link.js | 6 ++++++ .../app/components/sidebar/user/sections.hbs | 1 + .../tests/acceptance/sidebar-plugin-api-test.js | 14 +++++++++++++- .../discourse/initializers/chat-sidebar.js | 9 ++++++--- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/section-link.hbs b/app/assets/javascripts/discourse/app/components/sidebar/section-link.hbs index c29385e2c0..6be1ab4512 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/section-link.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/section-link.hbs @@ -1,5 +1,5 @@ {{#if this.shouldDisplay}} -