mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix void link for user address link
This commit is contained in:
@@ -3,7 +3,16 @@ import { Link } from "react-router-dom";
|
|||||||
|
|
||||||
const ForwardRefLink = React.forwardRef((props, ref) => {
|
const ForwardRefLink = React.forwardRef((props, ref) => {
|
||||||
const { children, setRefAndCid, onMouseOver, onMouseLeave, onClick, ...otherProps } = props;
|
const { children, setRefAndCid, onMouseOver, onMouseLeave, onClick, ...otherProps } = props;
|
||||||
|
|
||||||
|
const handleClick = (event) => {
|
||||||
|
if (otherProps.to === "#void") {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
if (onClick) {
|
||||||
|
onClick(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current && typeof setRefAndCid === 'function') {
|
if (ref.current && typeof setRefAndCid === 'function') {
|
||||||
setRefAndCid(ref.current);
|
setRefAndCid(ref.current);
|
||||||
@@ -16,7 +25,7 @@ const ForwardRefLink = React.forwardRef((props, ref) => {
|
|||||||
{...otherProps}
|
{...otherProps}
|
||||||
onMouseOver={onMouseOver}
|
onMouseOver={onMouseOver}
|
||||||
onMouseLeave={onMouseLeave}
|
onMouseLeave={onMouseLeave}
|
||||||
onClick={onClick}
|
onClick={handleClick}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ const Post = ({ content, postQuoteOnClick, postQuoteOnOver, postQuoteOnLeave, po
|
|||||||
const linkTarget = matchedText.startsWith('u/') ? "_blank" : "_self";
|
const linkTarget = matchedText.startsWith('u/') ? "_blank" : "_self";
|
||||||
|
|
||||||
if (matchedText.startsWith('u/')) {
|
if (matchedText.startsWith('u/')) {
|
||||||
linkTo = () => {};
|
linkTo = "#void";
|
||||||
} else if (matchedText.startsWith('p/') || matchedText.startsWith('p/')) {
|
} else if (matchedText.startsWith('p/') || matchedText.startsWith('p/')) {
|
||||||
linkTo = `/${matchedText}`;
|
linkTo = `/${matchedText}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user