mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
We have separated and combined modes for sidebar panels. Separated means the panels show only their own sections, combined means sections from all panels are shown. The admin sidebar only shows its own panels, so it must set the mode to separated; however when we navigate to chat or home we must revert to the initial mode setttings.
24 lines
747 B
JavaScript
24 lines
747 B
JavaScript
import { ADMIN_PANEL, 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 === ADMIN_PANEL) {
|
|
return;
|
|
}
|
|
|
|
api.setSidebarPanel(MAIN_PANEL);
|
|
}
|