mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
30 lines
795 B
JavaScript
30 lines
795 B
JavaScript
import { useEffect } from "react";
|
|
import { useAccount } from "@plebbit/plebbit-react-hooks";
|
|
import useAnonModeStore from "./stores/useAnonModeStore";
|
|
|
|
const useAnonMode = (threadCid, execute) => {
|
|
const account = useAccount();
|
|
const { anonymousMode } = useAnonModeStore();
|
|
|
|
useEffect(() => {
|
|
const handleAnonMode = async () => {
|
|
let storedSigners = JSON.parse(localStorage.getItem('storedSigners')) || {};
|
|
|
|
if (!anonymousMode) {
|
|
if (execute && storedSigners[threadCid]) {
|
|
const signerPrivateKey = storedSigners[threadCid];
|
|
if (account) {
|
|
await account.plebbit.createSigner({privateKey: signerPrivateKey});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
handleAnonMode();
|
|
}, [threadCid, execute, account, anonymousMode]);
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
export default useAnonMode; |