From c8eb1a275ccc869ec3ce122fb1946fce6d813b90 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 15 May 2023 08:14:50 +0200 Subject: [PATCH] UX: opens side panel early to avoid jitter (#21516) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hard to write a test for this behavior, this is a micro optimisation which doesn’t change the behavior but only makes it smoother by happening right before async request. --- .../discourse/routes/chat-channel-thread.js | 2 ++ .../discourse/routes/chat-channel-threads.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js index 362c385417e..2d0afb11038 100644 --- a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js +++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js @@ -59,5 +59,7 @@ export default class ChatChannelThread extends DiscourseRoute { return; } } + + this.chatStateManager.openSidePanel(); } } diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js index aca770abcd2..7f742b9cc38 100644 --- a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js +++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js @@ -1,9 +1,11 @@ import DiscourseRoute from "discourse/routes/discourse"; import { inject as service } from "@ember/service"; import { action } from "@ember/object"; + export default class ChatChannelThreads extends DiscourseRoute { @service router; @service chatChannelThreadListPane; + @service chatStateManager; beforeModel(transition) { const channel = this.modelFor("chat.channel"); @@ -13,11 +15,15 @@ export default class ChatChannelThreads extends DiscourseRoute { this.router.transitionTo("chat.channel", ...channel.routeModels); return; } + + this.chatStateManager.openSidePanel(); } @action - willTransition() { - this.chatChannelThreadListPane.close(); + willTransition(transition) { + if (transition.targetName !== "chat.channel.thread") { + this.chatChannelThreadListPane.close(); + } } activate() {