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
+3 -3
View File
@@ -198,7 +198,7 @@ const ReplyModal = ({ isOpen, closeModal }) => {
if (!storedSigners[selectedParentCid]) { if (!storedSigners[selectedParentCid]) {
signer = await account.plebbit.createSigner(); signer = await account.plebbit.createSigner();
storedSigners[selectedParentCid] = { privateKey: signer.privateKey, address: signer.address }; storedSigners[selectedParentCid] = { privateKey: signer?.privateKey, address: signer?.address };
localStorage.setItem('storedSigners', JSON.stringify(storedSigners)); localStorage.setItem('storedSigners', JSON.stringify(storedSigners));
} else { } else {
@@ -207,7 +207,7 @@ const ReplyModal = ({ isOpen, closeModal }) => {
try { try {
signer = await account.plebbit.createSigner({type: 'ed25519', privateKey: signerPrivateKey}); signer = await account.plebbit.createSigner({type: 'ed25519', privateKey: signerPrivateKey});
} catch (error) { } catch (error) {
setNewErrorMessage(error); console.log(error);
} }
} }
@@ -216,7 +216,7 @@ const ReplyModal = ({ isOpen, closeModal }) => {
signer, signer,
author: { author: {
...prevPublishCommentOptions.author, ...prevPublishCommentOptions.author,
address: signer.address address: signer?.address
}, },
})); }));
+3 -3
View File
@@ -390,7 +390,7 @@ const Board = () => {
if (!storedSigners[selectedThreadCidRef]) { if (!storedSigners[selectedThreadCidRef]) {
signer = await account.plebbit.createSigner(); signer = await account.plebbit.createSigner();
storedSigners[selectedThreadCidRef] = { privateKey: signer.privateKey, address: signer.address }; storedSigners[selectedThreadCidRef] = { privateKey: signer?.privateKey, address: signer?.address };
localStorage.setItem('storedSigners', JSON.stringify(storedSigners)); localStorage.setItem('storedSigners', JSON.stringify(storedSigners));
} else { } else {
@@ -399,7 +399,7 @@ const Board = () => {
try { try {
signer = await account.plebbit.createSigner({type: 'ed25519', privateKey: signerPrivateKey}); signer = await account.plebbit.createSigner({type: 'ed25519', privateKey: signerPrivateKey});
} catch (error) { } catch (error) {
setNewErrorMessage(error); console.log(error);
} }
} }
@@ -408,7 +408,7 @@ const Board = () => {
signer, signer,
author: { author: {
...prevPublishCommentOptions.author, ...prevPublishCommentOptions.author,
address: signer.address address: signer?.address
}, },
})); }));
+3 -3
View File
@@ -357,7 +357,7 @@ const Thread = () => {
if (!storedSigners[selectedThread]) { if (!storedSigners[selectedThread]) {
signer = await account.plebbit.createSigner(); signer = await account.plebbit.createSigner();
storedSigners[selectedThread] = { privateKey: signer.privateKey, address: signer.address }; storedSigners[selectedThread] = { privateKey: signer?.privateKey, address: signer?.address };
localStorage.setItem('storedSigners', JSON.stringify(storedSigners)); localStorage.setItem('storedSigners', JSON.stringify(storedSigners));
} else { } else {
@@ -366,7 +366,7 @@ const Thread = () => {
try { try {
signer = await account.plebbit.createSigner({type: 'ed25519', privateKey: signerPrivateKey}); signer = await account.plebbit.createSigner({type: 'ed25519', privateKey: signerPrivateKey});
} catch (error) { } catch (error) {
setNewErrorMessage(error); console.log(error);
} }
} }
@@ -375,7 +375,7 @@ const Thread = () => {
signer, signer,
author: { author: {
...prevPublishCommentOptions.author, ...prevPublishCommentOptions.author,
address: signer.address address: signer?.address
}, },
})); }));
+4 -2
View File
@@ -3,7 +3,7 @@ import { useAccount } from "@plebbit/plebbit-react-hooks";
import useAnonModeStore from "./stores/useAnonModeStore"; import useAnonModeStore from "./stores/useAnonModeStore";
const useAnonMode = (threadCid, execute) => { const useAnonMode = (threadCid, execute) => {
const { account } = useAccount(); const account = useAccount();
const { anonymousMode } = useAnonModeStore(); const { anonymousMode } = useAnonModeStore();
useEffect(() => { useEffect(() => {
@@ -13,7 +13,9 @@ useEffect(() => {
if (!anonymousMode) { if (!anonymousMode) {
if (execute && storedSigners[threadCid]) { if (execute && storedSigners[threadCid]) {
const signerPrivateKey = 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"; import useAnonModeStore from "./stores/useAnonModeStore";
const useAnonModeRef = (threadCidRef, execute) => { const useAnonModeRef = (threadCidRef, execute) => {
const { account } = useAccount(); const account = useAccount();
const { anonymousMode } = useAnonModeStore(); const { anonymousMode } = useAnonModeStore();
useEffect(() => { useEffect(() => {
@@ -13,13 +13,13 @@ const useAnonModeRef = (threadCidRef, execute) => {
if (!anonymousMode) return; if (!anonymousMode) return;
if (!storedSigners[threadCidRef] && execute) { if (!storedSigners[threadCidRef] && execute) {
const signer = await account.plebbit.createSigner(); const signer = await account?.plebbit.createSigner();
storedSigners[threadCidRef] = signer.privateKey; storedSigners[threadCidRef] = signer.privateKey;
localStorage.setItem('storedSigners', JSON.stringify(storedSigners)); localStorage.setItem('storedSigners', JSON.stringify(storedSigners));
} else { } else {
const signerPrivateKey = storedSigners[threadCidRef]; const signerPrivateKey = storedSigners[threadCidRef];
const signer = await account.plebbit.createSigner({privateKey: signerPrivateKey}); const signer = await account?.plebbit.createSigner({privateKey: signerPrivateKey});
await setActiveAccount(account, {signer}); await setActiveAccount(account, {signer});
} }
} }