import { useConsoleLogger } from "@/app/hooks/useConsoleLogger";
import { useMemoryClean } from "../MemoryProvider/useMemoryClean";
import { useAccountProvider } from "./useAccountProvider";
import { useDialogsList } from "../DialogListProvider/useDialogsList";
import { useProtocol } from "../ProtocolProvider/useProtocol";

export function useLogout() {
    const {loginAccount} = useAccountProvider();
    const {info} = useConsoleLogger('useLogout');
    const memClean = useMemoryClean();
    const {setDialogs} = useDialogsList();
    const {protocol} = useProtocol();

    const logout = () => {
        info("Logging out from account");
        memClean();
        loginAccount({
            publicKey: "",
            privateKey: "",
            seedPhraseEncrypted: "",
            privatePlain: "",
            privateHash: ""
        });
        setDialogs([]);
        protocol.close();
    }

    return logout;
}