Pass status to MediaModal, handle status undefined

merge-requests/1841/head
Alex Gleason 2022-10-18 19:10:16 -05:00
rodzic 44a2644fa9
commit fa7a517a95
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
5 zmienionych plików z 8 dodań i 8 usunięć

Wyświetl plik

@ -59,7 +59,7 @@ const StatusMedia: React.FC<IStatusMedia> = ({
};
const openMedia = (media: ImmutableList<Attachment>, index: number) => {
dispatch(openModal('MEDIA', { media, index }));
dispatch(openModal('MEDIA', { media, status, index }));
};
const openVideo = (media: Attachment, time: number): void => {

Wyświetl plik

@ -117,9 +117,9 @@ const Status: React.FC<IStatus> = (props) => {
if (firstAttachment) {
if (firstAttachment.type === 'video') {
dispatch(openModal('VIDEO', { media: firstAttachment, time: 0 }));
dispatch(openModal('VIDEO', { status, media: firstAttachment, time: 0 }));
} else {
dispatch(openModal('MEDIA', { media: status.media_attachments, index: 0 }));
dispatch(openModal('MEDIA', { status, media: status.media_attachments, index: 0 }));
}
}
};

Wyświetl plik

@ -27,7 +27,7 @@ const ReportStatus: React.FC<IReportStatus> = ({ status }) => {
const dispatch = useAppDispatch();
const handleOpenMedia = (media: Attachment, index: number) => {
dispatch(openModal('MEDIA', { media, index }));
dispatch(openModal('MEDIA', { media, status, index }));
};
const handleDeleteStatus = () => {

Wyświetl plik

@ -228,7 +228,7 @@ const Thread: React.FC<IThread> = (props) => {
};
const handleOpenMedia = (media: ImmutableList<AttachmentEntity>, index: number) => {
dispatch(openModal('MEDIA', { media, index }));
dispatch(openModal('MEDIA', { media, status, index }));
};
const handleOpenVideo = (media: ImmutableList<AttachmentEntity>, time: number) => {

Wyświetl plik

@ -23,7 +23,7 @@ const messages = defineMessages({
interface IMediaModal {
media: ImmutableList<Attachment>,
status: Status,
status?: Status,
account: Account,
index: number,
time?: number,
@ -96,7 +96,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
const handleStatusClick: React.MouseEventHandler = e => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
history.push(`/@${account.acct}/posts/${status.id}`);
history.push(`/@${account.acct}/posts/${status?.id}`);
onClose();
}
};
@ -209,7 +209,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
<Audio
src={attachment.url}
alt={attachment.description}
poster={attachment.preview_url !== attachment.url ? attachment.preview_url : (status.getIn(['account', 'avatar_static'])) as string | undefined}
poster={attachment.preview_url !== attachment.url ? attachment.preview_url : (status?.getIn(['account', 'avatar_static'])) as string | undefined}
backgroundColor={attachment.meta.getIn(['colors', 'background']) as string | undefined}
foregroundColor={attachment.meta.getIn(['colors', 'foreground']) as string | undefined}
accentColor={attachment.meta.getIn(['colors', 'accent']) as string | undefined}