From 990214d02c7575c5bbe429443d43900705095273 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 17 May 2022 10:03:37 -0400 Subject: [PATCH] Convert 'AttachmentThumbs' to TSX --- app/soapbox/components/attachment-thumbs.tsx | 44 ++++++++++++++++++ app/soapbox/components/attachment_thumbs.js | Bin 1458 -> 0 bytes app/soapbox/components/status.tsx | 4 +- .../compose/components/reply_indicator.js | Bin 1828 -> 1806 bytes .../components/scheduled_status.js | Bin 3697 -> 3673 bytes .../status/components/quoted_status.tsx | 3 +- .../ui/components/compare_history_modal.tsx | 7 +-- .../modals/report-modal/report-modal.tsx | 3 +- 8 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 app/soapbox/components/attachment-thumbs.tsx delete mode 100644 app/soapbox/components/attachment_thumbs.js diff --git a/app/soapbox/components/attachment-thumbs.tsx b/app/soapbox/components/attachment-thumbs.tsx new file mode 100644 index 0000000000..37b9fc9c6e --- /dev/null +++ b/app/soapbox/components/attachment-thumbs.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { useDispatch } from 'react-redux'; + +import { openModal } from 'soapbox/actions/modals'; +import Bundle from 'soapbox/features/ui/components/bundle'; +import { MediaGallery } from 'soapbox/features/ui/util/async-components'; + +import type { List as ImmutableList } from 'immutable'; + +interface IAttachmentThumbs { + media: ImmutableList> + onClick?(): void + sensitive?: boolean +} + +const AttachmentThumbs = (props: IAttachmentThumbs) => { + const { media, onClick, sensitive } = props; + const dispatch = useDispatch(); + + const renderLoading = () =>
; + const onOpenMedia = (media: Immutable.Record, index: number) => dispatch(openModal('MEDIA', { media, index })); + + return ( +
+ + {(Component: any) => ( + + )} + + + {onClick && ( +
+ )} +
+ ); +}; + +export default AttachmentThumbs; diff --git a/app/soapbox/components/attachment_thumbs.js b/app/soapbox/components/attachment_thumbs.js deleted file mode 100644 index 6c998e74405e4f9796b9e39b061bf494554d4428..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1458 zcmah}!H%0S5WVvib6P+Op_g8Em#EuqRjt&t)oSl62PVNP*c6*pB8z|T*nlCds^*f! zGk){ln+LpZWUJvR{co*=Y=NVb9$9ijj&!wlj?le18xW;jP z37^V|#a+S9ce@rJCCw5juI4Q7Q%{mlO)~)lxfBA4U%zCSv{-a!YMV3|kPV8xELi0` zm1NC9o>Nl9rBG>Ys|($qJ5f|P!cNUcWSY3BwBxDgqtb)xUGmyv!Pz%fRoGtMja;I1 znpY`P7m?2bEsFrpZbbziSyyTJG%AhaAg`EG@Sruz%bHAkDZBch0M8mlq2M3RnjipB znrWVc-N&%^3=ACu6kIh-=jH93iS4ly`If6^{L^uAbmJOpE9`bLWP;jOT`axf>hcG~^sZwj1$v$<@}Hq_&eWkxx(*?!SI{dI&dQ zV0j<?p@7{|9O2gU5bn6+I>3MHkZw~E4aD2(*56EyuRi(`S$fl@1qmF cV?s)wdm6F{w5Mo#?w-bdO1U1+r$F_=Uw7u!3;+NC diff --git a/app/soapbox/components/status.tsx b/app/soapbox/components/status.tsx index f2b804fbe3..3396b2d761 100644 --- a/app/soapbox/components/status.tsx +++ b/app/soapbox/components/status.tsx @@ -14,7 +14,7 @@ import Card from '../features/status/components/card'; import Bundle from '../features/ui/components/bundle'; import { MediaGallery, Video, Audio } from '../features/ui/util/async-components'; -import AttachmentThumbs from './attachment_thumbs'; +import AttachmentThumbs from './attachment-thumbs'; import StatusActionBar from './status_action_bar'; import StatusContent from './status_content'; import StatusReplyMentions from './status_reply_mentions'; @@ -160,7 +160,7 @@ class Status extends ImmutablePureComponent { // Compensate height changes componentDidUpdate(_prevProps: IStatus, _prevState: IStatusState, snapshot?: ScrollPosition): void { - const doShowCard: boolean = Boolean(!this.props.muted && !this.props.hidden && this.props.status && this.props.status.card); + const doShowCard: boolean = Boolean(!this.props.muted && !this.props.hidden && this.props.status && this.props.status.card); if (doShowCard && !this.didShowCard) { this.didShowCard = true; diff --git a/app/soapbox/features/compose/components/reply_indicator.js b/app/soapbox/features/compose/components/reply_indicator.js index 7063970b3e665253d4ae3766379dda2d21e10bc3..faa86ea9aaf670806ae53fa1e742f5ecb28a80a8 100644 GIT binary patch delta 21 dcmZ3&*T*;E52NnJzeY@(4Vi { {status.media_attachments.size > 0 && ( diff --git a/app/soapbox/features/ui/components/compare_history_modal.tsx b/app/soapbox/features/ui/components/compare_history_modal.tsx index d0ab73d55a..648c0709fe 100644 --- a/app/soapbox/features/ui/components/compare_history_modal.tsx +++ b/app/soapbox/features/ui/components/compare_history_modal.tsx @@ -4,7 +4,7 @@ import React, { useEffect } from 'react'; import { FormattedDate, FormattedMessage } from 'react-intl'; import { fetchHistory } from 'soapbox/actions/history'; -import AttachmentThumbs from 'soapbox/components/attachment_thumbs'; +import AttachmentThumbs from 'soapbox/components/attachment-thumbs'; import { HStack, Modal, Spinner, Stack, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; @@ -75,10 +75,7 @@ const CompareHistoryModal: React.FC = ({ onClose, statusId )} {version.media_attachments.size > 0 && ( - + )} diff --git a/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx b/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx index 536f680eec..997abb1cd5 100644 --- a/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx +++ b/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx @@ -6,7 +6,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { blockAccount } from 'soapbox/actions/accounts'; import { submitReport, submitReportSuccess, submitReportFail } from 'soapbox/actions/reports'; import { expandAccountTimeline } from 'soapbox/actions/timelines'; -import AttachmentThumbs from 'soapbox/components/attachment_thumbs'; +import AttachmentThumbs from 'soapbox/components/attachment-thumbs'; import StatusContent from 'soapbox/components/status_content'; import { Modal, ProgressBar, Stack, Text } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account_container'; @@ -61,7 +61,6 @@ const SelectedStatus = ({ statusId }: { statusId: string }) => { {status.get('media_attachments').size > 0 && (