mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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.
27 lines
790 B
JavaScript
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);
|
|
}
|