fix displayname in post form, anon mode

This commit is contained in:
Tom (plebeius.eth)
2024-08-25 19:37:04 +02:00
parent 1695fa0c81
commit 449cd967ec
+8 -16
View File
@@ -164,7 +164,7 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
signer: newSigner, signer: newSigner,
author: { author: {
address: newSigner.address, address: newSigner.address,
displayName: account?.author?.displayName, displayName: displayName || undefined,
}, },
}); });
} }
@@ -173,11 +173,11 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
signer: undefined, signer: undefined,
author: { author: {
address: account?.author?.address, address: account?.author?.address,
displayName: account?.author?.displayName, displayName: displayName || undefined,
}, },
}); });
} }
}, [anonMode, getNewSigner, account, setSubmitStore]); }, [anonMode, getNewSigner, account, setSubmitStore, displayName]);
const onPublishPost = async () => { const onPublishPost = async () => {
if (!title && !content && !link) { if (!title && !content && !link) {
@@ -189,16 +189,6 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
return; return;
} }
if (!anonMode) {
setSubmitStore({
signer: undefined,
author: {
address: account?.author?.address,
displayName: account?.author?.displayName,
},
});
}
publishComment(); publishComment();
}; };
@@ -235,6 +225,7 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
signer: existingSigner, signer: existingSigner,
author: { author: {
address: existingSigner.address, address: existingSigner.address,
displayName: displayName || undefined,
}, },
}); });
} else { } else {
@@ -243,11 +234,12 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
signer: newSigner, signer: newSigner,
author: { author: {
address: newSigner.address, address: newSigner.address,
displayName: displayName || undefined,
}, },
}); });
} }
} }
}, [address, getExistingSigner, getNewSigner, setPublishReplyOptions, anonMode]); }, [address, getExistingSigner, getNewSigner, setPublishReplyOptions, anonMode, displayName]);
const onPublishReply = () => { const onPublishReply = () => {
const currentContent = textRef.current?.value || ''; const currentContent = textRef.current?.value || '';
@@ -297,9 +289,9 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
onChange={(e) => { onChange={(e) => {
setAccount({ ...account, author: { ...account?.author, displayName: e.target.value } }); setAccount({ ...account, author: { ...account?.author, displayName: e.target.value } });
if (isInPostView) { if (isInPostView) {
setPublishReplyOptions({ displayName: e.target.value }); setPublishReplyOptions({ displayName: e.target.value || undefined });
} else { } else {
setSubmitStore({ displayName: e.target.value }); setSubmitStore({ displayName: e.target.value || undefined });
} }
}} }}
/> />