mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
b6744dcd29
* dev: Mobx integration for app sidebar and custom theme * dev: Handled edge case and conditional rendering for mobx store
34 lines
882 B
TypeScript
34 lines
882 B
TypeScript
import { useEffect } from "react";
|
|
// mobx store
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
const MobxStoreInit = () => {
|
|
const store: any = useMobxStore();
|
|
|
|
useEffect(() => {
|
|
// sidebar collapsed toggle
|
|
if (
|
|
localStorage &&
|
|
localStorage.getItem("app_sidebar_collapsed") &&
|
|
store?.theme?.sidebarCollapsed === null
|
|
)
|
|
store.theme.setSidebarCollapsed(
|
|
localStorage.getItem("app_sidebar_collapsed")
|
|
? localStorage.getItem("app_sidebar_collapsed") === "true"
|
|
? true
|
|
: false
|
|
: false
|
|
);
|
|
|
|
// theme
|
|
if (localStorage && localStorage.getItem("theme") && store.theme.theme === null)
|
|
store.theme.setTheme(
|
|
localStorage.getItem("theme") ? localStorage.getItem("theme") : "system"
|
|
);
|
|
}, [store?.theme]);
|
|
|
|
return <></>;
|
|
};
|
|
|
|
export default MobxStoreInit;
|