Fix preview for local collection links (#38793)

This commit is contained in:
diondiondion 2026-04-23 13:47:31 +02:00 committed by GitHub
parent 478dae0ab3
commit d7b60a2cb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 4 deletions

View File

@ -31,6 +31,7 @@ import { getHashtagBarForStatus } from './hashtag_bar';
import StatusActionBar from './status_action_bar'; import StatusActionBar from './status_action_bar';
import StatusContent from './status_content'; import StatusContent from './status_content';
import { StatusThreadLabel } from './status_thread_label'; import { StatusThreadLabel } from './status_thread_label';
import { CollectionPreviewCard } from '../features/collections/components/collection_preview_card';
const domParser = new DOMParser(); const domParser = new DOMParser();
@ -564,6 +565,13 @@ class Status extends ImmutablePureComponent {
/> />
); );
} }
} else if (status.get('tagged_collections').size) {
const firstLinkedCollection = status.get('tagged_collections').first();
if (firstLinkedCollection) {
media = (
<CollectionPreviewCard collection={firstLinkedCollection.toJS()} />
);
}
} }
const {statusContentProps, hashtagBar} = getHashtagBarForStatus(status); const {statusContentProps, hashtagBar} = getHashtagBarForStatus(status);

View File

@ -1,3 +1,5 @@
import classNames from 'classnames';
import type { CollectionLockupProps } from 'mastodon/features/collections/components/collection_lockup'; import type { CollectionLockupProps } from 'mastodon/features/collections/components/collection_lockup';
import { CollectionLockup } from 'mastodon/features/collections/components/collection_lockup'; import { CollectionLockup } from 'mastodon/features/collections/components/collection_lockup';
@ -13,7 +15,7 @@ export const CollectionPreviewCard: React.FC<CollectionPreviewCardProps> = ({
...otherProps ...otherProps
}) => { }) => {
return ( return (
<div className={classes.wrapper}> <div className={classNames(classes.wrapper, 'collection-preview')}>
<CollectionLockup collection={collection} {...otherProps} /> <CollectionLockup collection={collection} {...otherProps} />
</div> </div>
); );

View File

@ -282,6 +282,13 @@ export const DetailedStatus: React.FC<{
/> />
); );
} }
} else if (status.get('tagged_collections').size) {
const firstLinkedCollection = status.get('tagged_collections').first();
if (firstLinkedCollection) {
media = (
<CollectionPreviewCard collection={firstLinkedCollection.toJS()} />
);
}
} }
if (status.get('application')) { if (status.get('application')) {

View File

@ -1499,8 +1499,9 @@ body > [data-popper-placement] {
.media-gallery, .media-gallery,
.video-player, .video-player,
.audio-player, .audio-player,
.attachment-list { .attachment-list,
margin-top: 16px; .collection-preview {
margin-top: 14px;
} }
&--in-thread { &--in-thread {
@ -1517,6 +1518,7 @@ body > [data-popper-placement] {
& > .picture-in-picture-placeholder, & > .picture-in-picture-placeholder,
& > .more-from-author, & > .more-from-author,
& > .status-card, & > .status-card,
& > .collection-preview,
& > .hashtag-bar, & > .hashtag-bar,
& > .content-warning, & > .content-warning,
& > .filter-warning, & > .filter-warning,
@ -1787,7 +1789,8 @@ body > [data-popper-placement] {
.media-gallery, .media-gallery,
.video-player, .video-player,
.audio-player { .audio-player,
.collection-preview {
margin-top: 16px; margin-top: 16px;
} }