From 697779b7e237b7fe2847f16f45ac379a18f8ba63 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 31 Jan 2023 10:16:45 +0100 Subject: [PATCH] UX: brings back URL on chat icon when in full page (#20092) --- .../discourse/components/chat-header-icon.hbs | 30 +++++++------------ .../discourse/components/chat-header-icon.js | 16 ++++++---- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.hbs index c363c95fe96..bb5bdced654 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.hbs @@ -1,21 +1,11 @@ -{{#if (and this.chatStateManager.isFullPageActive this.site.desktopView)}} - - {{d-icon "comment"}} + + {{d-icon "comment"}} - {{#unless this.currentUserInDnD}} - - {{/unless}} - -{{else}} - - {{d-icon "comment"}} - - {{#unless this.currentUserInDnD}} - - {{/unless}} - -{{/if}} \ No newline at end of file + {{#unless this.currentUserInDnD}} + + {{/unless}} + diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.js b/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.js index 9753f8ab005..c69b44ca868 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-header-icon.js @@ -1,25 +1,31 @@ import { inject as service } from "@ember/service"; import Component from "@glimmer/component"; +import getURL from "discourse-common/lib/get-url"; export default class ChatHeaderIcon extends Component { @service currentUser; @service site; @service chatStateManager; + @service router; get currentUserInDnD() { return this.currentUser.isInDoNotDisturb(); } get href() { - if (this.chatStateManager.isFullPageActive && this.site.mobileView) { - return "/chat"; + if (this.chatStateManager.isFullPageActive) { + if (this.site.mobileView) { + return getURL("/chat"); + } else { + return getURL(this.router.currentURL); + } } if (this.chatStateManager.isDrawerActive) { - return "/chat"; - } else { - return this.chatStateManager.lastKnownChatURL || "/chat"; + return getURL("/chat"); } + + return getURL(this.chatStateManager.lastKnownChatURL || "/chat"); } get isActive() {