mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 13:49:29 +08:00
FIX: sets sidebar state on load (#23150)
This commit was incorrectly removed of https://github.com/discourse/discourse/pull/23078 and would set the state only on entering (or exiting) chat route. The tests were already present in the previous PR.
This commit is contained in:
parent
b2b84cc957
commit
3d86fc1391
|
@ -12,6 +12,7 @@ import { until } from "discourse/lib/formatter";
|
|||
import { inject as service } from "@ember/service";
|
||||
import ChatModalNewMessage from "discourse/plugins/chat/discourse/components/chat/modal/new-message";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import { initSidebarState } from "discourse/plugins/chat/discourse/lib/init-sidebar-state";
|
||||
|
||||
export default {
|
||||
name: "chat-sidebar",
|
||||
|
@ -34,6 +35,8 @@ export default {
|
|||
switchButtonDefaultUrl = getURL("/chat");
|
||||
}
|
||||
);
|
||||
|
||||
initSidebarState(api, api.getCurrentUser());
|
||||
});
|
||||
|
||||
withPluginApi("1.3.0", (api) => {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { getUserChatSeparateSidebarMode } from "discourse/plugins/chat/discourse/lib/get-user-chat-separate-sidebar-mode";
|
||||
|
||||
export function initSidebarState(api, user) {
|
||||
api.setSidebarPanel("main");
|
||||
|
||||
const chatSeparateSidebarMode = getUserChatSeparateSidebarMode(user);
|
||||
if (chatSeparateSidebarMode.fullscreen) {
|
||||
api.setCombinedSidebarMode();
|
||||
api.showSidebarSwitchPanelButtons();
|
||||
} else if (chatSeparateSidebarMode.always) {
|
||||
api.setSeparatedSidebarMode();
|
||||
} else {
|
||||
api.setCombinedSidebarMode();
|
||||
api.hideSidebarSwitchPanelButtons();
|
||||
}
|
||||
}
|
|
@ -5,7 +5,9 @@ import { inject as service } from "@ember/service";
|
|||
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { initSidebarState } from "discourse/plugins/chat/discourse/lib/init-sidebar-state";
|
||||
import { getUserChatSeparateSidebarMode } from "discourse/plugins/chat/discourse/lib/get-user-chat-separate-sidebar-mode";
|
||||
|
||||
export default class ChatRoute extends DiscourseRoute {
|
||||
@service chat;
|
||||
@service router;
|
||||
|
@ -81,20 +83,7 @@ export default class ChatRoute extends DiscourseRoute {
|
|||
|
||||
deactivate(transition) {
|
||||
withPluginApi("1.8.0", (api) => {
|
||||
api.setSidebarPanel("main");
|
||||
|
||||
const chatSeparateSidebarMode = getUserChatSeparateSidebarMode(
|
||||
this.currentUser
|
||||
);
|
||||
if (chatSeparateSidebarMode.fullscreen) {
|
||||
api.setCombinedSidebarMode();
|
||||
api.showSidebarSwitchPanelButtons();
|
||||
} else if (chatSeparateSidebarMode.always) {
|
||||
api.setSeparatedSidebarMode();
|
||||
} else {
|
||||
api.setCombinedSidebarMode();
|
||||
api.hideSidebarSwitchPanelButtons();
|
||||
}
|
||||
initSidebarState(api, this.currentUser);
|
||||
});
|
||||
|
||||
if (transition) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user