fix(post menu): 'view on (client)' link was broken on multisubs

This commit is contained in:
Tom (plebeius.eth)
2024-08-13 15:59:17 +02:00
parent 43561e9077
commit 25722d74a3
2 changed files with 36 additions and 5 deletions
@@ -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>