mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix incorrect thread URL to redirect
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|||||||
import { Helmet } from 'react-helmet-async';
|
import { Helmet } from 'react-helmet-async';
|
||||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
import { Tooltip } from 'react-tooltip';
|
import { Tooltip } from 'react-tooltip';
|
||||||
import { useAccount, useAccountComments, useComment, usePublishComment } from '@plebbit/plebbit-react-hooks';
|
import { useAccount, useAccountComments, useComment, usePublishComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||||
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils'
|
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils'
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||||
@@ -38,7 +38,7 @@ const Thread = () => {
|
|||||||
setResolveCaptchaPromise,
|
setResolveCaptchaPromise,
|
||||||
setPendingComment,
|
setPendingComment,
|
||||||
setPendingCommentIndex,
|
setPendingCommentIndex,
|
||||||
selectedAddress, setSelectedAddress,
|
setSelectedAddress,
|
||||||
setSelectedParentCid,
|
setSelectedParentCid,
|
||||||
setSelectedShortCid,
|
setSelectedShortCid,
|
||||||
selectedStyle,
|
selectedStyle,
|
||||||
@@ -65,12 +65,24 @@ const Thread = () => {
|
|||||||
const comment = useComment({commentCid: selectedThread});
|
const comment = useComment({commentCid: selectedThread});
|
||||||
const { subplebbitAddress, threadCid } = useParams();
|
const { subplebbitAddress, threadCid } = useParams();
|
||||||
const handleClickForm = useClickForm();
|
const handleClickForm = useClickForm();
|
||||||
|
const subplebbit = useSubplebbit({subplebbitAddress: comment.subplebbitAddress});
|
||||||
|
const selectedAddress = subplebbit.address;
|
||||||
|
|
||||||
const stateString = useStateString(comment?.clients);
|
const stateString = useStateString(comment?.clients);
|
||||||
|
|
||||||
const commentMediaInfo = getCommentMediaInfo(comment);
|
const commentMediaInfo = getCommentMediaInfo(comment);
|
||||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if ( comment.state !== "initializing" && selectedAddress === undefined) {
|
||||||
|
navigate('/404');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (comment.state === "failed" && subplebbitAddress !== selectedAddress) {
|
||||||
|
navigate(`/p/${selectedAddress}/c/${threadCid}`);
|
||||||
|
}
|
||||||
|
}, [subplebbitAddress, selectedAddress, navigate, threadCid, comment.state]);
|
||||||
|
|
||||||
|
|
||||||
const errorString = useMemo(() => {
|
const errorString = useMemo(() => {
|
||||||
if (comment?.state === 'failed') {
|
if (comment?.state === 'failed') {
|
||||||
|
|||||||
Reference in New Issue
Block a user