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