Fixed dark mode not activating immediatly at refresh (#1666)
Changed location of dark listener to improve dark performance
This commit is contained in:
parent
db01d7e589
commit
895eea688a
4 changed files with 14 additions and 11 deletions
|
|
@ -11,7 +11,7 @@
|
|||
></script>
|
||||
<title>Langflow</title>
|
||||
</head>
|
||||
<body id="body" style="width: 100%; height: 100%">
|
||||
<body id="body" class="dark" style="width: 100%; height: 100%">
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div style="width: 100vw; height: 100vh" id="root"></div>
|
||||
<script type="module" src="/src/index.tsx"></script>
|
||||
|
|
|
|||
|
|
@ -50,9 +50,18 @@ export default function App() {
|
|||
);
|
||||
const checkHasStore = useStoreStore((state) => state.checkHasStore);
|
||||
const navigate = useNavigate();
|
||||
const dark = useDarkStore((state) => state.dark);
|
||||
|
||||
const [isLoadingHealth, setIsLoadingHealth] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!dark) {
|
||||
document.getElementById("body")!.classList.remove("dark");
|
||||
} else {
|
||||
document.getElementById("body")!.classList.add("dark");
|
||||
}
|
||||
}, [dark]);
|
||||
|
||||
useEffect(() => {
|
||||
const isLoginPage = location.pathname.includes("login");
|
||||
|
||||
|
|
|
|||
|
|
@ -40,15 +40,6 @@ export default function Header(): JSX.Element {
|
|||
const setDark = useDarkStore((state) => state.setDark);
|
||||
const stars = useDarkStore((state) => state.stars);
|
||||
|
||||
useEffect(() => {
|
||||
if (dark) {
|
||||
document.getElementById("body")!.classList.add("dark");
|
||||
} else {
|
||||
document.getElementById("body")!.classList.remove("dark");
|
||||
}
|
||||
window.localStorage.setItem("isDark", dark.toString());
|
||||
}, [dark]);
|
||||
|
||||
async function checkForChanges(nodes: Node[]): Promise<void> {
|
||||
if (nodes.length === 0) {
|
||||
await removeFlow(id!);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ export const useDarkStore = create<DarkStoreType>((set, get) => ({
|
|||
dark: JSON.parse(window.localStorage.getItem("isDark")!) ?? false,
|
||||
stars: startedStars,
|
||||
version: "",
|
||||
setDark: (dark) => set(() => ({ dark: dark })),
|
||||
setDark: (dark) => {
|
||||
set(() => ({ dark: dark }));
|
||||
window.localStorage.setItem("isDark", dark.toString());
|
||||
},
|
||||
refreshVersion: () => {
|
||||
getVersion().then((data) => {
|
||||
set(() => ({ version: data.version }));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue