Prefer to/href for DropdownMenuItems

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-04-28 11:24:59 +02:00
parent 0b2e370705
commit fd65f7f71e
4 changed files with 10 additions and 22 deletions

View File

@ -263,10 +263,6 @@ const Header: React.FC<IHeader> = ({ account }) => {
}
};
const handleRssFeedClick = () => {
window.open(software === MASTODON ? `${account.url}.rss` : `${account.url}/feed.rss`, '_blank');
};
const handleShare = () => {
navigator.share({
text: `@${account.acct}`,
@ -290,8 +286,9 @@ const Header: React.FC<IHeader> = ({ account }) => {
if (features.rssFeeds && account.local) {
menu.push({
text: intl.formatMessage(messages.subscribeFeed),
action: handleRssFeedClick,
icon: require('@tabler/icons/outline/rss.svg'),
href: software === MASTODON ? `${account.url}.rss` : `${account.url}/feed.rss`,
target: '_blank',
});
}

View File

@ -113,10 +113,6 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
copy(uri);
};
const handleExternalClick = () => {
window.open(status.uri, '_blank');
};
const handleBookmarkClick = () => {
dispatch(toggleBookmark(status));
};
@ -218,8 +214,9 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
if (features.federating && !account.local) {
menu.push({
text: intl.formatMessage(messages.external, { domain }),
action: handleExternalClick,
icon: require('@tabler/icons/outline/external-link.svg'),
href: status.uri,
target: '_blank',
});
}
@ -393,8 +390,8 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
if (typeof menuItem?.text === 'undefined') {
return <MenuDivider key={idx} />;
} else {
const Comp = (menuItem.action ? MenuItem : MenuLink) as any;
const itemProps = menuItem.action ? { onSelect: menuItem.action } : { to: menuItem.to, as: Link, target: menuItem.target || '_self' };
const Comp = (menuItem.href ? MenuLink : MenuItem) as any;
const itemProps = menuItem.href ? { href: menuItem.href, target: menuItem.target || '_self' } : { onSelect: menuItem.action };
return (
<Comp key={idx} {...itemProps} className='group'>