mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix onChallenge assertion error
This commit is contained in:
@@ -122,20 +122,6 @@ const Board = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const publishCommentOptions = {
|
|
||||||
displayName: nameRef.current ? nameRef.current.value : undefined,
|
|
||||||
title: subjectRef.current ? subjectRef.current.value : undefined,
|
|
||||||
content: commentRef.current ? commentRef.current.value : undefined,
|
|
||||||
link: linkRef.current ? linkRef.current.value : undefined,
|
|
||||||
subplebbitAddress: selectedAddress,
|
|
||||||
onChallenge,
|
|
||||||
onChallengeVerification,
|
|
||||||
onError: (error) => {
|
|
||||||
setErrorMessage(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const resetFields = () => {
|
const resetFields = () => {
|
||||||
nameRef.current.value = '';
|
nameRef.current.value = '';
|
||||||
subjectRef.current.value = '';
|
subjectRef.current.value = '';
|
||||||
@@ -144,6 +130,39 @@ const Board = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const [publishCommentOptions, setPublishCommentOptions] = useState({
|
||||||
|
subplebbitAddress: selectedAddress,
|
||||||
|
onChallenge,
|
||||||
|
onChallengeVerification,
|
||||||
|
onError: (error) => {
|
||||||
|
setErrorMessage(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const handleSubmit = async (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
setPublishCommentOptions((prevPublishCommentOptions) => ({
|
||||||
|
...prevPublishCommentOptions,
|
||||||
|
displayName: nameRef.current.value || undefined,
|
||||||
|
title: subjectRef.current.value || undefined,
|
||||||
|
content: commentRef.current.value || undefined,
|
||||||
|
link: linkRef.current.value || undefined,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (publishCommentOptions.content) {
|
||||||
|
(async () => {
|
||||||
|
await publishComment();
|
||||||
|
resetFields();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}, [publishCommentOptions]);
|
||||||
|
|
||||||
|
|
||||||
const { publishComment } = usePublishComment(publishCommentOptions);
|
const { publishComment } = usePublishComment(publishCommentOptions);
|
||||||
|
|
||||||
|
|
||||||
@@ -295,7 +314,7 @@ const Board = () => {
|
|||||||
<td>
|
<td>
|
||||||
<input name="sub" type="text" tabIndex={3} ref={subjectRef}/>
|
<input name="sub" type="text" tabIndex={3} ref={subjectRef}/>
|
||||||
<input id="post-button" type="submit" value="Post" tabIndex={6}
|
<input id="post-button" type="submit" value="Post" tabIndex={6}
|
||||||
onClick={async () => {await publishComment(); resetFields();}} />
|
onClick={handleSubmit} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr data-type="Comment">
|
<tr data-type="Comment">
|
||||||
|
|||||||
Reference in New Issue
Block a user