mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(post menu): 'view on (client)' link was broken on multisubs
This commit is contained in:
@@ -73,7 +73,20 @@ const ImageSearchButton = ({ url, onClose }: { url: string; onClose: () => void
|
||||
const ViewOnButton = ({ cid, isDescription, isInAllView, isInSubscriptionsView, isRules, subplebbitAddress, onClose }: PostMenuDesktopProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||
const viewOnOtherClientLink = `p/${isInAllView ? 'all' : isInSubscriptionsView ? 'subscriptions' : subplebbitAddress}${isDescription || isRules ? '' : `/c/${cid}`}`;
|
||||
|
||||
const getViewOnOtherClientLink = () => {
|
||||
if (isDescription || isRules) {
|
||||
if (isInAllView || isInSubscriptionsView) {
|
||||
return `${isInAllView ? 'all' : isInSubscriptionsView && 'subscriptions'}`;
|
||||
} else {
|
||||
return `${subplebbitAddress}/${isDescription ? 'description' : isRules && 'rules'}`;
|
||||
}
|
||||
} else {
|
||||
return `${subplebbitAddress}/c/${cid}`;
|
||||
}
|
||||
};
|
||||
|
||||
const viewOnOtherClientLink = getViewOnOtherClientLink();
|
||||
|
||||
const { refs, floatingStyles } = useFloating({
|
||||
placement: 'right-start',
|
||||
@@ -91,10 +104,10 @@ const ViewOnButton = ({ cid, isDescription, isInAllView, isInSubscriptionsView,
|
||||
{_.capitalize(t('view_on'))} »
|
||||
{isClientRedirectMenuOpen && (
|
||||
<div ref={refs.setFloating} style={floatingStyles} className={styles.dropdownMenu}>
|
||||
<a href={`https://seedit.eth.limo/#/${viewOnOtherClientLink}`} target='_blank' rel='noreferrer'>
|
||||
<a href={`https://seedit.eth.limo/#/p/${viewOnOtherClientLink}`} target='_blank' rel='noreferrer'>
|
||||
<div className={styles.postMenuItem}>Seedit</div>
|
||||
</a>
|
||||
<a href={`https://plebones.eth.limo/#/${viewOnOtherClientLink}`} target='_blank' rel='noreferrer'>
|
||||
<a href={`https://plebones.eth.limo/#/p/${viewOnOtherClientLink}`} target='_blank' rel='noreferrer'>
|
||||
<div className={styles.postMenuItem}>Plebones</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { copyShareLinkToClipboard, isValidURL } from '../../../lib/utils/url-uti
|
||||
import useEditCommentPrivileges from '../../../hooks/use-author-privileges';
|
||||
import useHide from '../../../hooks/use-hide';
|
||||
import EditMenu from '../../edit-menu/edit-menu';
|
||||
import { isBoardView, isPostPageView } from '../../../lib/utils/view-utils';
|
||||
import { isAllView, isBoardView, isPostPageView, isSubscriptionsView } from '../../../lib/utils/view-utils';
|
||||
import { useLocation, useParams } from 'react-router-dom';
|
||||
|
||||
interface PostMenuMobileProps {
|
||||
@@ -57,7 +57,25 @@ const ImageSearchButtons = ({ url, onClose }: { url: string; onClose: () => void
|
||||
|
||||
const ViewOnButtons = ({ cid, isDescription, isRules, subplebbitAddress, onClose }: PostMenuMobileProps) => {
|
||||
const { t } = useTranslation();
|
||||
const viewOnOtherClientLink = `p/${subplebbitAddress}${isDescription || isRules ? '' : `/c/${cid}`}`;
|
||||
const location = useLocation();
|
||||
const params = useParams();
|
||||
const isInAllView = isAllView(location.pathname, params);
|
||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
|
||||
|
||||
const getViewOnOtherClientLink = () => {
|
||||
if (isDescription || isRules) {
|
||||
if (isInAllView || isInSubscriptionsView) {
|
||||
return `${isInAllView ? 'all' : isInSubscriptionsView && 'subscriptions'}`;
|
||||
} else {
|
||||
return `${subplebbitAddress}/${isDescription ? 'description' : isRules && 'rules'}`;
|
||||
}
|
||||
} else {
|
||||
return `${subplebbitAddress}/c/${cid}`;
|
||||
}
|
||||
};
|
||||
|
||||
const viewOnOtherClientLink = getViewOnOtherClientLink();
|
||||
|
||||
return (
|
||||
<div onClick={onClose}>
|
||||
<a href={`https://seedit.eth.limo/#/${viewOnOtherClientLink}`} target='_blank' rel='noreferrer'>
|
||||
|
||||
Reference in New Issue
Block a user