Show collection preview cards and open collections links locally (#38643)
This commit is contained in:
1 parent
a8741495c4
commit
478dae0ab3
11 files changed
+92
-32
No files matched your search
@@ -18,6 +18,7 @@ import { languages as preloadedLanguages } from 'mastodon/initial_state';
|
||||
import { EmojiHTML } from './emoji/html';
|
||||
import { injectIntl } from './intl';
|
||||
import { HandledLink } from './status/handled_link';
|
||||
import { compareUrls } from '../utils/compare_urls';
|
||||
|
||||
const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
|
||||
|
||||
@@ -71,17 +72,6 @@ const mapStateToProps = state => ({
|
||||
languages: state.getIn(['server', 'translationLanguages', 'items']),
|
||||
});
|
||||
|
||||
const compareUrls = (href1, href2) => {
|
||||
try {
|
||||
const url1 = new URL(href1);
|
||||
const url2 = new URL(href2);
|
||||
|
||||
return url1.origin === url2.origin && url1.pathname === url2.pathname && url1.search === url2.search;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class StatusContent extends PureComponent {
|
||||
static propTypes = {
|
||||
identity: identityContextPropShape,
|
||||
@@ -166,7 +156,13 @@ class StatusContent extends PureComponent {
|
||||
|
||||
handleElement = (element, { key, ...props }, children) => {
|
||||
if (element instanceof HTMLAnchorElement) {
|
||||
const mention = this.props.status.get('mentions').find(item => compareUrls(element.href, item.get('url')));
|
||||
const mention = this.props.status.get('mentions').find(
|
||||
item => compareUrls(element.href, item.get('url'))
|
||||
);
|
||||
const taggedCollection = this.props.status.get('tagged_collections').find(
|
||||
item => compareUrls(element.href, item.get('url'))
|
||||
)
|
||||
|
||||
return (
|
||||
<HandledLink
|
||||
{...props}
|
||||
@@ -174,6 +170,7 @@ class StatusContent extends PureComponent {
|
||||
text={element.innerText}
|
||||
hashtagAccountId={this.props.status.getIn(['account', 'id'])}
|
||||
mention={mention?.toJSON()}
|
||||
collection={taggedCollection?.toJSON()}
|
||||
key={key}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in new issue
Block a user