Display 'View context' link when it actually makes sense

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
media-view-context
marcin mikołajczak 2023-05-24 18:12:44 +02:00
rodzic 0a397c1cfe
commit e03143283b
6 zmienionych plików z 16 dodań i 13 usunięć

Wyświetl plik

@ -86,12 +86,12 @@ const AccountGallery = () => {
const handleOpenMedia = (attachment: Attachment) => {
if (attachment.type === 'video') {
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status, account: attachment.account }));
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status, account: attachment.account, showLink: true }));
} else {
const media = (attachment.status as Status).media_attachments;
const index = media.findIndex((x) => x.id === attachment.id);
dispatch(openModal('MEDIA', { media, index, status: attachment.status }));
dispatch(openModal('MEDIA', { media, index, status: attachment.status, showLink: true }));
}
};

Wyświetl plik

@ -38,12 +38,12 @@ const GroupGallery: React.FC<IGroupGallery> = (props) => {
const handleOpenMedia = (attachment: Attachment) => {
if (attachment.type === 'video') {
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status, account: attachment.account }));
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status, account: attachment.account, showLink: true }));
} else {
const media = (attachment.status as Status).media_attachments;
const index = media.findIndex((x) => x.id === attachment.id);
dispatch(openModal('MEDIA', { media, index, status: attachment.status }));
dispatch(openModal('MEDIA', { media, index, status: attachment.status, showLink: true }));
}
};

Wyświetl plik

@ -28,12 +28,12 @@ const GroupMediaPanel: React.FC<IGroupMediaPanel> = ({ group }) => {
const handleOpenMedia = (attachment: Attachment): void => {
if (attachment.type === 'video') {
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status }));
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status, showLink: true }));
} else {
const media = attachment.getIn(['status', 'media_attachments']) as ImmutableList<Attachment>;
const index = media.findIndex(x => x.id === attachment.id);
dispatch(openModal('MEDIA', { media, index, status: attachment.status, account: attachment.account }));
dispatch(openModal('MEDIA', { media, index, status: attachment.status, account: attachment.account, showLink: true }));
}
};

Wyświetl plik

@ -28,6 +28,7 @@ interface IMediaModal {
index: number
time?: number
onClose: () => void
showLink?: boolean
}
const MediaModal: React.FC<IMediaModal> = (props) => {
@ -36,6 +37,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
status,
onClose,
time = 0,
showLink,
} = props;
const intl = useIntl();
@ -164,11 +166,11 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
const width = (attachment.meta.getIn(['original', 'width']) || undefined) as number | undefined;
const height = (attachment.meta.getIn(['original', 'height']) || undefined) as number | undefined;
const link = (status && (
const link = showLink && status && (
<a href={status.url} onClick={handleStatusClick}>
<FormattedMessage id='lightbox.view_context' defaultMessage='View context' />
</a>
));
);
if (attachment.type === 'image') {
return (
@ -275,7 +277,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
{leftNav}
{rightNav}
{(status && !isMultiMedia[getIndex()]) && (
{(showLink && status && !isMultiMedia[getIndex()]) && (
<div className={clsx('media-modal__meta', { 'media-modal__meta--shifted': media.size > 1 })}>
<a href={status.url} onClick={handleStatusClick}>
<FormattedMessage id='lightbox.view_context' defaultMessage='View context' />

Wyświetl plik

@ -12,9 +12,10 @@ interface IVideoModal {
account: Account
time: number
onClose: () => void
showLink?: boolean
}
const VideoModal: React.FC<IVideoModal> = ({ status, account, media, time, onClose }) => {
const VideoModal: React.FC<IVideoModal> = ({ status, account, media, time, showLink }) => {
const history = useHistory();
const handleStatusClick: React.MouseEventHandler = e => {
@ -24,7 +25,7 @@ const VideoModal: React.FC<IVideoModal> = ({ status, account, media, time, onClo
}
};
const link = status && account && (
const link = showLink && status && (
<a href={status.url} onClick={handleStatusClick}>
<FormattedMessage id='lightbox.view_context' defaultMessage='View context' />
</a>

Wyświetl plik

@ -25,12 +25,12 @@ const ProfileMediaPanel: React.FC<IProfileMediaPanel> = ({ account }) => {
const handleOpenMedia = (attachment: Attachment): void => {
if (attachment.type === 'video') {
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status }));
dispatch(openModal('VIDEO', { media: attachment, status: attachment.status, showLink: true }));
} else {
const media = attachment.getIn(['status', 'media_attachments']) as ImmutableList<Attachment>;
const index = media.findIndex(x => x.id === attachment.id);
dispatch(openModal('MEDIA', { media, index, status: attachment.status }));
dispatch(openModal('MEDIA', { media, index, status: attachment.status, showLink: true }));
}
};