Fix undefined bug with MediaModal
This commit is contained in:
parent
1b7fec2fec
commit
e1e5051951
3 changed files with 5 additions and 7 deletions
|
@ -95,7 +95,7 @@ const AccountGallery = () => {
|
||||||
const media = (attachment.status as Status).media_attachments;
|
const media = (attachment.status as Status).media_attachments;
|
||||||
const index = media.findIndex((x) => x.id === attachment.id);
|
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 }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ const messages = defineMessages({
|
||||||
interface IMediaModal {
|
interface IMediaModal {
|
||||||
media: ImmutableList<Attachment>,
|
media: ImmutableList<Attachment>,
|
||||||
status?: Status,
|
status?: Status,
|
||||||
account: Account,
|
|
||||||
index: number,
|
index: number,
|
||||||
time?: number,
|
time?: number,
|
||||||
onClose: () => void,
|
onClose: () => void,
|
||||||
|
@ -34,7 +33,6 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
const {
|
const {
|
||||||
media,
|
media,
|
||||||
status,
|
status,
|
||||||
account,
|
|
||||||
onClose,
|
onClose,
|
||||||
time = 0,
|
time = 0,
|
||||||
} = props;
|
} = props;
|
||||||
|
@ -94,9 +92,9 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleStatusClick: React.MouseEventHandler = e => {
|
const handleStatusClick: React.MouseEventHandler = e => {
|
||||||
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
if (status && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
history.push(`/@${account.acct}/posts/${status?.id}`);
|
history.push(`/@${status.getIn(['account', 'acct'])}/posts/${status?.id}`);
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -170,7 +168,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
const width = (attachment.meta.getIn(['original', 'width']) || undefined) as number | undefined;
|
const width = (attachment.meta.getIn(['original', 'width']) || undefined) as number | undefined;
|
||||||
const height = (attachment.meta.getIn(['original', 'height']) || undefined) as number | undefined;
|
const height = (attachment.meta.getIn(['original', 'height']) || undefined) as number | undefined;
|
||||||
|
|
||||||
const link = (status && account && (
|
const link = (status && (
|
||||||
<a href={status.url} onClick={handleStatusClick}>
|
<a href={status.url} onClick={handleStatusClick}>
|
||||||
<FormattedMessage id='lightbox.view_context' defaultMessage='View context' />
|
<FormattedMessage id='lightbox.view_context' defaultMessage='View context' />
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -31,7 +31,7 @@ const ProfileMediaPanel: React.FC<IProfileMediaPanel> = ({ account }) => {
|
||||||
const media = attachment.getIn(['status', 'media_attachments']) as ImmutableList<Attachment>;
|
const media = attachment.getIn(['status', 'media_attachments']) as ImmutableList<Attachment>;
|
||||||
const index = media.findIndex(x => x.id === attachment.id);
|
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 }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue