remove onLinkClick

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-07-09 23:59:41 +02:00
parent ec040ff253
commit 1805dec968

View file

@ -34,10 +34,12 @@ const AnnouncementContent: React.FC<IAnnouncementContent> = ({ announcement }) =
} }
}; };
/** For regular links, just stop propogation */ // const onStatusClick = (status, e: MouseEvent) => {
const onLinkClick = (e: MouseEvent) => { // if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.stopPropagation(); // e.preventDefault();
}; // history.push(`/@${status.getIn(['account', 'acct'])}/${status.get('id')}`);
// }
// };
const updateLinks = () => { const updateLinks = () => {
if (!node.current) return; if (!node.current) return;
@ -55,15 +57,19 @@ const AnnouncementContent: React.FC<IAnnouncementContent> = ({ announcement }) =
const mention = announcement.mentions.find(mention => link.href === `${mention.url}`); const mention = announcement.mentions.find(mention => link.href === `${mention.url}`);
// Add event listeners on mentions and hashtags // Add event listeners on mentions, hashtags and statuses
if (mention) { if (mention) {
link.addEventListener('click', onMentionClick.bind(link, mention), false); link.addEventListener('click', onMentionClick.bind(link, mention), false);
link.setAttribute('title', mention.acct); link.setAttribute('title', mention.acct);
} else if (link.textContent?.charAt(0) === '#' || (link.previousSibling?.textContent?.charAt(link.previousSibling.textContent.length - 1) === '#')) { } else if (link.textContent?.charAt(0) === '#' || (link.previousSibling?.textContent?.charAt(link.previousSibling.textContent.length - 1) === '#')) {
link.addEventListener('click', onHashtagClick.bind(link, link.text), false); link.addEventListener('click', onHashtagClick.bind(link, link.text), false);
} else { // } else {
link.setAttribute('title', link.href); // const status = announcement.statuses.find(item => link.href === item.get('url'));
link.addEventListener('click', onLinkClick.bind(link), false); // if (status) {
// link.addEventListener('click', onStatusClick.bind(this, status), false);
// }
// link.setAttribute('title', link.href);
// link.classList.add('unhandled-link');
} }
}); });
}; };