[Glitch] Fix preview for local collection links

Port d7b60a2cb6496938d86b17a707e0b49a7fae3a9b to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion 2026-04-23 13:47:31 +02:00 committed by Claire
parent 0e4878c733
commit 5bcb9ae43d
4 changed files with 23 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import StatusActionBar from './status_action_bar';
import StatusContent from './status_content'; import StatusContent from './status_content';
import StatusIcons from './status_icons'; import StatusIcons from './status_icons';
import StatusPrepend from './status_prepend'; import StatusPrepend from './status_prepend';
import { CollectionPreviewCard } from '../features/collections/components/collection_preview_card';
const domParser = new DOMParser(); const domParser = new DOMParser();
@ -659,6 +660,13 @@ class Status extends ImmutablePureComponent {
); );
} }
mediaIcons.push('link'); mediaIcons.push('link');
} else if (status.get('tagged_collections').size && settings.get('inline_preview_cards') && !this.props.muted) {
const firstLinkedCollection = status.get('tagged_collections').first();
if (firstLinkedCollection) {
media = (
<CollectionPreviewCard collection={firstLinkedCollection.toJS()} />
);
}
} }
if (status.get('poll')) { if (status.get('poll')) {

View File

@ -1,3 +1,5 @@
import classNames from 'classnames';
import type { CollectionLockupProps } from 'flavours/glitch/features/collections/components/collection_lockup'; import type { CollectionLockupProps } from 'flavours/glitch/features/collections/components/collection_lockup';
import { CollectionLockup } from 'flavours/glitch/features/collections/components/collection_lockup'; import { CollectionLockup } from 'flavours/glitch/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

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

View File

@ -1558,7 +1558,8 @@ body > [data-popper-placement] {
.media-gallery, .media-gallery,
.video-player, .video-player,
.audio-player, .audio-player,
.attachment-list { .attachment-list,
.collection-preview {
margin-top: 8px; // glitch: reduced margins margin-top: 8px; // glitch: reduced margins
} }
@ -1576,6 +1577,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,
@ -1853,7 +1855,8 @@ body > [data-popper-placement] {
.media-gallery, .media-gallery,
.video-player, .video-player,
.audio-player { .audio-player,
.collection-preview {
margin-top: 8px; // glitch: reduced margins margin-top: 8px; // glitch: reduced margins
} }