Files
discourse/plugins/chat/assets/javascripts/discourse/lib/init-sidebar-state.js
Sérgio Saquetim 08d5cf01cd FIX: Don't override other sidebar panels when opening/closing the chat drawer (#29144)
This commit fixes an issue where the following happens:

1. The user opens a page where an alternative sidebar panel is displayed like /admin or other page where a plugin is displaying an alternative sidebar like the `docs-categories` plugin
2. Clicking the chat icon in the header and opening the drawer, or if you just minimize chat into drawer after it opens full-screen
3. The alternative sidebar panel is lost and reverted to the main panel.
2024-10-09 20:29:19 -03:00

27 lines
790 B
JavaScript

import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
import { getUserChatSeparateSidebarMode } from "discourse/plugins/chat/discourse/lib/get-user-chat-separate-sidebar-mode";
export const CHAT_PANEL = "chat";
export function initSidebarState(api, user) {
const chatSeparateSidebarMode = getUserChatSeparateSidebarMode(user);
if (chatSeparateSidebarMode.fullscreen) {
api.setCombinedSidebarMode();
api.showSidebarSwitchPanelButtons();
} else if (chatSeparateSidebarMode.always) {
api.setSeparatedSidebarMode();
} else {
api.setCombinedSidebarMode();
api.hideSidebarSwitchPanelButtons();
}
if (
api.getSidebarPanel()?.key !== MAIN_PANEL &&
api.getSidebarPanel()?.key !== CHAT_PANEL
) {
return;
}
api.setSidebarPanel(MAIN_PANEL);
}