mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-06-03 14:20:10 +02:00
9fc45daf77
reopen if chat was last opened
17 lines
502 B
JavaScript
17 lines
502 B
JavaScript
import { CHAT_UI_REOPEN } from "@/utils/constants";
|
|
import { useState } from "react";
|
|
|
|
export default function useOpenChat() {
|
|
const [isOpen, setOpen] = useState(
|
|
!!window?.localStorage?.getItem(CHAT_UI_REOPEN) || false
|
|
);
|
|
|
|
function toggleOpenChat(newValue) {
|
|
if (newValue === true) window.localStorage.setItem(CHAT_UI_REOPEN, "1");
|
|
if (newValue === false) window.localStorage.removeItem(CHAT_UI_REOPEN);
|
|
setOpen(newValue);
|
|
}
|
|
|
|
return { isChatOpen: isOpen, toggleOpenChat };
|
|
}
|