fix anon mode

This commit is contained in:
Tom (plebeius.eth)
2024-08-25 18:58:38 +02:00
parent a0f83304e5
commit 899239e10e
3 changed files with 40 additions and 48 deletions
-8
View File
@@ -266,14 +266,6 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
publishReply();
};
const hasSetInitialDisplayName = useRef(false);
useEffect(() => {
if (!hasSetInitialDisplayName.current && displayName) {
setPublishReplyOptions({ displayName });
hasSetInitialDisplayName.current = true;
}
}, [displayName, setPublishReplyOptions]);
useEffect(() => {
if (typeof replyIndex === 'number') {
resetPublishReplyOptions();
+9 -16
View File
@@ -39,7 +39,6 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
const address = comment?.author?.address;
const hasCalledAnonAddressRef = useRef(false);
const getAnonAddressForReply = useCallback(async () => {
if (anonMode && !hasCalledAnonAddressRef.current) {
hasCalledAnonAddressRef.current = true;
@@ -49,6 +48,7 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
signer: existingSigner,
author: {
address: existingSigner.address,
displayName: displayName || undefined,
},
});
} else {
@@ -57,17 +57,12 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
signer: newSigner,
author: {
address: newSigner.address,
displayName: displayName || undefined,
},
});
}
}
}, [anonMode, address, getExistingSigner, getNewSigner, setPublishReplyOptions]);
useEffect(() => {
if (anonMode) {
getAnonAddressForReply();
}
}, [anonMode, getAnonAddressForReply]);
}, [address, getExistingSigner, getNewSigner, setPublishReplyOptions, anonMode, displayName]);
const onPublishReply = () => {
const currentContent = textRef.current?.value || '';
@@ -86,6 +81,12 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
publishReply();
};
useEffect(() => {
if (anonMode) {
getAnonAddressForReply();
}
}, [anonMode, getAnonAddressForReply]);
useEffect(() => {
if (typeof replyIndex === 'number') {
resetPublishReplyOptions();
@@ -93,14 +94,6 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
}
}, [replyIndex, resetPublishReplyOptions, closeModal]);
const hasSetInitialDisplayName = useRef(false);
useEffect(() => {
if (!hasSetInitialDisplayName.current && displayName) {
setPublishReplyOptions({ displayName });
hasSetInitialDisplayName.current = true;
}
}, [displayName, setPublishReplyOptions]);
const nodeRef = useRef<HTMLDivElement>(null);
const isMobile = useIsMobile();