fix(edit menu): mod and author edits were conflicting

This commit is contained in:
Tom (plebeius.eth)
2024-06-15 12:35:09 +02:00
parent ca5c08a3f9
commit efc9a98f47
+10 -9
View File
@@ -42,25 +42,25 @@ const EditMenu = ({ commentCid, isAccountMod, isAccountCommentAuthor, isCommentA
} }
}, []); }, []);
const defaultPublishOptions: PublishCommentEditOptions = { const defaultPublishEditOptions: PublishCommentEditOptions = {
commentAuthor: { banExpiresAt }, commentAuthor: isAccountMod && !isAccountCommentAuthor && banExpiresAt !== undefined ? { banExpiresAt } : undefined,
commentCid, commentCid,
content, content: isAccountCommentAuthor ? content : undefined,
deleted, deleted: isAccountCommentAuthor ? deleted : undefined,
locked, locked: isAccountMod ? locked : undefined,
pinned, pinned: isAccountMod ? pinned : undefined,
removed, removed: isAccountMod ? removed : undefined,
spoiler, spoiler,
subplebbitAddress, subplebbitAddress,
onChallenge: (...args: any) => addChallenge([...args, post]), onChallenge: (...args: any) => addChallenge([...args, post]),
onChallengeVerification: alertChallengeVerificationFailed, onChallengeVerification: alertChallengeVerificationFailed,
onError: (error: Error) => { onError: (error: Error) => {
console.warn(error); console.warn(error);
alert(error.message); alert('Comment edit failed. ' + error.message);
}, },
}; };
const [publishCommentEditOptions, setPublishCommentEditOptions] = useState(defaultPublishOptions); const [publishCommentEditOptions, setPublishCommentEditOptions] = useState(defaultPublishEditOptions);
const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions);
const [banDuration, setBanDuration] = useState(1); const [banDuration, setBanDuration] = useState(1);
@@ -112,6 +112,7 @@ const EditMenu = ({ commentCid, isAccountMod, isAccountCommentAuthor, isCommentA
const headingId = useId(); const headingId = useId();
const _publishCommentEdit = async () => { const _publishCommentEdit = async () => {
console.log('publishCommentEditOptions', publishCommentEditOptions);
try { try {
await publishCommentEdit(); await publishCommentEdit();
} catch (error) { } catch (error) {