StatusContent: refactor updateStatusLinks, remove reblogContent prop
This commit is contained in:
parent
2cfb151542
commit
be9bfa6409
2 changed files with 9 additions and 16 deletions
|
@ -342,7 +342,7 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
render() {
|
render() {
|
||||||
let media = null;
|
let media = null;
|
||||||
const poll = null;
|
const poll = null;
|
||||||
let prepend, rebloggedByText, reblogContent, reblogElement, reblogElementMobile;
|
let prepend, rebloggedByText, reblogElement, reblogElementMobile;
|
||||||
|
|
||||||
const { intl, hidden, featured, unread, group } = this.props;
|
const { intl, hidden, featured, unread, group } = this.props;
|
||||||
|
|
||||||
|
@ -447,7 +447,6 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
|
|
||||||
// @ts-ignore what the FUCK
|
// @ts-ignore what the FUCK
|
||||||
account = status.account;
|
account = status.account;
|
||||||
reblogContent = status.contentHtml;
|
|
||||||
status = status.reblog;
|
status = status.reblog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +645,6 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
|
|
||||||
<StatusContent
|
<StatusContent
|
||||||
status={status}
|
status={status}
|
||||||
reblogContent={reblogContent}
|
|
||||||
onClick={this.handleClick}
|
onClick={this.handleClick}
|
||||||
expanded={!status.hidden}
|
expanded={!status.hidden}
|
||||||
onExpandedToggle={this.handleExpandedToggle}
|
onExpandedToggle={this.handleExpandedToggle}
|
||||||
|
|
|
@ -65,7 +65,6 @@ const SpoilerButton: React.FC<ISpoilerButton> = ({ onClick, hidden, tabIndex })
|
||||||
|
|
||||||
interface IStatusContent {
|
interface IStatusContent {
|
||||||
status: Status,
|
status: Status,
|
||||||
reblogContent?: string, // FIXME: not used!
|
|
||||||
expanded?: boolean,
|
expanded?: boolean,
|
||||||
onExpandedToggle?: () => void,
|
onExpandedToggle?: () => void,
|
||||||
onClick?: () => void,
|
onClick?: () => void,
|
||||||
|
@ -106,26 +105,27 @@ const StatusContent: React.FC<IStatusContent> = ({ status, expanded = false, onE
|
||||||
|
|
||||||
const links = node.current.querySelectorAll('a');
|
const links = node.current.querySelectorAll('a');
|
||||||
|
|
||||||
for (let i = 0; i < links.length; ++i) {
|
links.forEach(link => {
|
||||||
const link = links[i];
|
// Skip already processed
|
||||||
if (link.classList.contains('status-link')) {
|
if (link.classList.contains('status-link')) return;
|
||||||
continue;
|
|
||||||
}
|
// Add attributes
|
||||||
link.classList.add('status-link');
|
link.classList.add('status-link');
|
||||||
link.setAttribute('rel', 'nofollow noopener');
|
link.setAttribute('rel', 'nofollow noopener');
|
||||||
link.setAttribute('target', '_blank');
|
link.setAttribute('target', '_blank');
|
||||||
|
|
||||||
const mention = status.mentions.find(mention => link.href === `${mention.url}`);
|
const mention = status.mentions.find(mention => link.href === `${mention.url}`);
|
||||||
|
|
||||||
|
// Add event listeners on mentions and hashtags
|
||||||
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 && 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);
|
link.addEventListener('click', onHashtagClick.bind(link, link.text), false);
|
||||||
} else {
|
} else {
|
||||||
link.setAttribute('title', link.href);
|
link.setAttribute('title', link.href);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const maybeSetCollapsed = (): void => {
|
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 getHtmlContent = (): string => {
|
||||||
const { contentHtml: html } = status;
|
const { contentHtml: html } = status;
|
||||||
if (greentext) return addGreentext(html);
|
if (greentext) return addGreentext(html);
|
||||||
|
|
Loading…
Reference in a new issue