StatusContent: refactor updateStatusLinks, remove reblogContent prop

This commit is contained in:
Alex Gleason 2022-04-15 17:51:12 -05:00
parent 2cfb151542
commit be9bfa6409
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 9 additions and 16 deletions

View file

@ -342,7 +342,7 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
render() {
let media = null;
const poll = null;
let prepend, rebloggedByText, reblogContent, reblogElement, reblogElementMobile;
let prepend, rebloggedByText, reblogElement, reblogElementMobile;
const { intl, hidden, featured, unread, group } = this.props;
@ -447,7 +447,6 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
// @ts-ignore what the FUCK
account = status.account;
reblogContent = status.contentHtml;
status = status.reblog;
}
@ -646,7 +645,6 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
<StatusContent
status={status}
reblogContent={reblogContent}
onClick={this.handleClick}
expanded={!status.hidden}
onExpandedToggle={this.handleExpandedToggle}

View file

@ -65,7 +65,6 @@ const SpoilerButton: React.FC<ISpoilerButton> = ({ onClick, hidden, tabIndex })
interface IStatusContent {
status: Status,
reblogContent?: string, // FIXME: not used!
expanded?: boolean,
onExpandedToggle?: () => void,
onClick?: () => void,
@ -106,26 +105,27 @@ const StatusContent: React.FC<IStatusContent> = ({ status, expanded = false, onE
const links = node.current.querySelectorAll('a');
for (let i = 0; i < links.length; ++i) {
const link = links[i];
if (link.classList.contains('status-link')) {
continue;
}
links.forEach(link => {
// Skip already processed
if (link.classList.contains('status-link')) return;
// Add attributes
link.classList.add('status-link');
link.setAttribute('rel', 'nofollow noopener');
link.setAttribute('target', '_blank');
const mention = status.mentions.find(mention => link.href === `${mention.url}`);
// Add event listeners on mentions and hashtags
if (mention) {
link.addEventListener('click', onMentionClick.bind(link, mention), false);
link.setAttribute('title', mention.acct);
} else if (link.textContent?.charAt(0) === '#' || (link.previousSibling && link.previousSibling.textContent && link.previousSibling.textContent[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);
} else {
link.setAttribute('title', link.href);
}
}
});
};
const maybeSetCollapsed = (): void => {
@ -192,11 +192,6 @@ const StatusContent: React.FC<IStatusContent> = ({ status, expanded = false, onE
}
};
// const handleCollapsedClick: React.EventHandler<React.MouseEvent> = (e) => {
// e.preventDefault();
// setCollapsed(!collapsed);
// };
const getHtmlContent = (): string => {
const { contentHtml: html } = status;
if (greentext) return addGreentext(html);