2023-08-11 11:48:33 +00:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
import { useEffect } from "react";
|
2023-08-30 07:19:15 +00:00
|
|
|
// next imports
|
|
|
|
import { useSearchParams } from "next/navigation";
|
2023-08-11 11:48:33 +00:00
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
import { RootStore } from "store/root";
|
|
|
|
|
|
|
|
const MobxStoreInit = () => {
|
|
|
|
const store: RootStore = useMobxStore();
|
|
|
|
|
2023-08-30 07:19:15 +00:00
|
|
|
// search params
|
|
|
|
const routerSearchparams = useSearchParams();
|
|
|
|
|
2023-08-11 11:48:33 +00:00
|
|
|
useEffect(() => {
|
|
|
|
// theme
|
|
|
|
const _theme = localStorage && localStorage.getItem("app_theme") ? localStorage.getItem("app_theme") : "light";
|
|
|
|
if (_theme && store?.theme?.theme != _theme) store.theme.setTheme(_theme);
|
|
|
|
else localStorage.setItem("app_theme", _theme && _theme != "light" ? "dark" : "light");
|
|
|
|
}, [store?.theme]);
|
|
|
|
|
2023-08-30 07:19:15 +00:00
|
|
|
useEffect(() => {
|
|
|
|
if (!routerSearchparams) return;
|
|
|
|
|
|
|
|
const states = routerSearchparams.get("states");
|
|
|
|
const labels = routerSearchparams.get("labels");
|
|
|
|
const priorities = routerSearchparams.get("priorities");
|
|
|
|
|
|
|
|
store.issue.userSelectedLabels = labels?.split(",") || [];
|
|
|
|
store.issue.userSelectedPriorities = priorities?.split(",") || [];
|
|
|
|
store.issue.userSelectedStates = states?.split(",") || [];
|
|
|
|
}, [routerSearchparams, store.issue]);
|
|
|
|
|
2023-08-11 11:48:33 +00:00
|
|
|
return <></>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default MobxStoreInit;
|