mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add setPendingCommentIndex
This commit is contained in:
@@ -39,7 +39,6 @@ const CaptchaModal = () => {
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
submitCaptcha();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user