From fa7a517a95579a6da59437e725fc56c161362458 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 18 Oct 2022 19:10:16 -0500 Subject: [PATCH] Pass status to MediaModal, handle status undefined --- app/soapbox/components/status-media.tsx | 2 +- app/soapbox/components/status.tsx | 4 ++-- app/soapbox/features/admin/components/report_status.tsx | 2 +- app/soapbox/features/status/index.tsx | 2 +- app/soapbox/features/ui/components/media-modal.tsx | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/soapbox/components/status-media.tsx b/app/soapbox/components/status-media.tsx index 2721d726b..0052a9564 100644 --- a/app/soapbox/components/status-media.tsx +++ b/app/soapbox/components/status-media.tsx @@ -59,7 +59,7 @@ const StatusMedia: React.FC = ({ }; const openMedia = (media: ImmutableList, index: number) => { - dispatch(openModal('MEDIA', { media, index })); + dispatch(openModal('MEDIA', { media, status, index })); }; const openVideo = (media: Attachment, time: number): void => { diff --git a/app/soapbox/components/status.tsx b/app/soapbox/components/status.tsx index 99de0da5d..27b1731bd 100644 --- a/app/soapbox/components/status.tsx +++ b/app/soapbox/components/status.tsx @@ -117,9 +117,9 @@ const Status: React.FC = (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 })); } } }; diff --git a/app/soapbox/features/admin/components/report_status.tsx b/app/soapbox/features/admin/components/report_status.tsx index 8ec01792e..4f9ff1af0 100644 --- a/app/soapbox/features/admin/components/report_status.tsx +++ b/app/soapbox/features/admin/components/report_status.tsx @@ -27,7 +27,7 @@ const ReportStatus: React.FC = ({ status }) => { const dispatch = useAppDispatch(); const handleOpenMedia = (media: Attachment, index: number) => { - dispatch(openModal('MEDIA', { media, index })); + dispatch(openModal('MEDIA', { media, status, index })); }; const handleDeleteStatus = () => { diff --git a/app/soapbox/features/status/index.tsx b/app/soapbox/features/status/index.tsx index c5130b759..2ba338bcc 100644 --- a/app/soapbox/features/status/index.tsx +++ b/app/soapbox/features/status/index.tsx @@ -228,7 +228,7 @@ const Thread: React.FC = (props) => { }; const handleOpenMedia = (media: ImmutableList, index: number) => { - dispatch(openModal('MEDIA', { media, index })); + dispatch(openModal('MEDIA', { media, status, index })); }; const handleOpenVideo = (media: ImmutableList, time: number) => { diff --git a/app/soapbox/features/ui/components/media-modal.tsx b/app/soapbox/features/ui/components/media-modal.tsx index a04808ece..0ceea724e 100644 --- a/app/soapbox/features/ui/components/media-modal.tsx +++ b/app/soapbox/features/ui/components/media-modal.tsx @@ -23,7 +23,7 @@ const messages = defineMessages({ interface IMediaModal { media: ImmutableList, - status: Status, + status?: Status, account: Account, index: number, time?: number, @@ -96,7 +96,7 @@ const MediaModal: React.FC = (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 = (props) => {