Create a comment edit
Create a comment edit in Bitsocial React Hooks. Usage, options, and examples.
const publishCommentEditOptions = {
commentCid: "QmZVYzLChjKrYDVty6e5JokKffGDZivmEJz9318EYfp2ui",
content: "edited content",
communityAddress: "news.eth",
onChallenge,
onChallengeVerification,
onError,
};
const { state, error, publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions);
await publishCommentEdit();
console.log(state);
console.log(error);
// view the status of a comment edit instantly
let comment = useComment({ commentCid: publishCommentEditOptions.commentCid });
const { state: editedCommentState, editedComment } = useEditedComment({ comment });
// if the comment has a succeeded, failed or pending edit, use the edited comment
if (editedComment) {
comment = editedComment;
}
let editLabel;
if (editedCommentState === "succeeded") {
editLabel = { text: "EDITED", color: "green" };
}
if (editedCommentState === "pending") {
editLabel = { text: "PENDING EDIT", color: "orange" };
}
if (editedCommentState === "failed") {
editLabel = { text: "FAILED EDIT", color: "red" };
}