add setPendingCommentIndex

This commit is contained in:
plebbitor
2023-04-24 15:48:30 +02:00
parent 04cdd9f445
commit 661f925f07
9 changed files with 41 additions and 4 deletions
-1
View File
@@ -39,7 +39,6 @@ const CaptchaModal = () => {
const handleKeyDown = (event) => {
if (event.key === "Enter") {
event.preventDefault();
submitCaptcha();
}
};
+10 -1
View File
@@ -1,4 +1,5 @@
import React, { useRef, useState, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { usePublishComment } from '@plebbit/plebbit-react-hooks';
import { StyledModal } from './styled/ReplyModal.styled';
import useGeneralStore from '../hooks/stores/useGeneralStore';
@@ -13,6 +14,7 @@ const ReplyModal = ({ isOpen, closeModal }) => {
setChallengesArray,
setIsCaptchaOpen,
setPendingComment,
setPendingCommentIndex,
setResolveCaptchaPromise,
selectedAddress,
selectedParentCid,
@@ -29,6 +31,7 @@ const ReplyModal = ({ isOpen, closeModal }) => {
const [errorMessage, setErrorMessage] = useState(null);
useError(errorMessage, [errorMessage]);
const location = useLocation();
const onChallengeVerification = (challengeVerification) => {
if (challengeVerification.challengeSuccess === true) {
@@ -74,7 +77,13 @@ const ReplyModal = ({ isOpen, closeModal }) => {
});
const { publishComment } = usePublishComment(publishCommentOptions);
const { publishComment, index } = usePublishComment(publishCommentOptions);
useEffect(() => {
if (index !== undefined) {
setPendingCommentIndex(index);
}
}, [index, location]);
const resetFields = () => {
+2
View File
@@ -32,6 +32,7 @@ const Board = () => {
setIsCaptchaOpen,
isSettingsOpen, setIsSettingsOpen,
setPendingComment,
setPendingCommentIndex,
setResolveCaptchaPromise,
selectedAddress, setSelectedAddress,
setSelectedParentCid,
@@ -145,6 +146,7 @@ const Board = () => {
useEffect(() => {
if (index !== undefined) {
setPendingCommentIndex(index);
navigate(`/profile/c/${index}`);
}
}, [index]);
+2
View File
@@ -25,6 +25,7 @@ const Catalog = () => {
setIsCaptchaOpen,
isSettingsOpen, setIsSettingsOpen,
setPendingComment,
setPendingCommentIndex,
setResolveCaptchaPromise,
selectedAddress, setSelectedAddress,
selectedStyle,
@@ -127,6 +128,7 @@ const Catalog = () => {
useEffect(() => {
if (index !== undefined) {
setPendingCommentIndex(index);
navigate(`/profile/c/${index}`);
}
}, [index]);
+6 -1
View File
@@ -33,6 +33,7 @@ const Thread = () => {
isSettingsOpen, setIsSettingsOpen,
setResolveCaptchaPromise,
pendingComment, setPendingComment,
setPendingCommentIndex,
selectedAddress, setSelectedAddress,
setSelectedParentCid,
setSelectedShortCid,
@@ -137,7 +138,7 @@ const Thread = () => {
useEffect(() => {
if (index !== undefined) {
window.scrollTo(0, document.body.scrollHeight);
setPendingCommentIndex(index);
}
}, [index]);
@@ -151,6 +152,10 @@ const Thread = () => {
const handleSubmit = async (event) => {
event.preventDefault();
setTimeout(() => {
window.scrollTo(0, document.body.scrollHeight);
}, 100)
setPublishCommentOptions((prevPublishCommentOptions) => ({
...prevPublishCommentOptions,