fix errors

This commit is contained in:
plebeius.eth
2023-06-26 22:07:32 +02:00
parent c630d08acf
commit cd1b62af4e
5 changed files with 16 additions and 14 deletions
+4 -2
View File
@@ -3,7 +3,7 @@ import { useAccount } from "@plebbit/plebbit-react-hooks";
import useAnonModeStore from "./stores/useAnonModeStore";
const useAnonMode = (threadCid, execute) => {
const { account } = useAccount();
const account = useAccount();
const { anonymousMode } = useAnonModeStore();
useEffect(() => {
@@ -13,7 +13,9 @@ useEffect(() => {
if (!anonymousMode) {
if (execute && storedSigners[threadCid]) {
const signerPrivateKey = storedSigners[threadCid];
await account.plebbit.createSigner({privateKey: signerPrivateKey});
if (account) {
await account.plebbit.createSigner({privateKey: signerPrivateKey});
}
}
}
}
+3 -3
View File
@@ -3,7 +3,7 @@ import { setActiveAccount, useAccount } from "@plebbit/plebbit-react-hooks";
import useAnonModeStore from "./stores/useAnonModeStore";
const useAnonModeRef = (threadCidRef, execute) => {
const { account } = useAccount();
const account = useAccount();
const { anonymousMode } = useAnonModeStore();
useEffect(() => {
@@ -13,13 +13,13 @@ const useAnonModeRef = (threadCidRef, execute) => {
if (!anonymousMode) return;
if (!storedSigners[threadCidRef] && execute) {
const signer = await account.plebbit.createSigner();
const signer = await account?.plebbit.createSigner();
storedSigners[threadCidRef] = signer.privateKey;
localStorage.setItem('storedSigners', JSON.stringify(storedSigners));
} else {
const signerPrivateKey = storedSigners[threadCidRef];
const signer = await account.plebbit.createSigner({privateKey: signerPrivateKey});
const signer = await account?.plebbit.createSigner({privateKey: signerPrivateKey});
await setActiveAccount(account, {signer});
}
}