From 63b90718b7d4c256bb62e60df70f2226ef6ecabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 6 Apr 2022 23:59:00 +0200 Subject: [PATCH] next MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/components/attachment_list.js | 59 ---------------------- app/soapbox/components/attachment_list.tsx | 54 ++++++++++++++++++++ 2 files changed, 54 insertions(+), 59 deletions(-) delete mode 100644 app/soapbox/components/attachment_list.js create mode 100644 app/soapbox/components/attachment_list.tsx diff --git a/app/soapbox/components/attachment_list.js b/app/soapbox/components/attachment_list.js deleted file mode 100644 index 52d4e6d77..000000000 --- a/app/soapbox/components/attachment_list.js +++ /dev/null @@ -1,59 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import ImmutablePureComponent from 'react-immutable-pure-component'; - -import Icon from 'soapbox/components/icon'; - -const filename = url => url.split('/').pop().split('#')[0].split('?')[0]; - -export default class AttachmentList extends ImmutablePureComponent { - - static propTypes = { - media: ImmutablePropTypes.list.isRequired, - compact: PropTypes.bool, - }; - - render() { - const { media, compact } = this.props; - - if (compact) { - return ( -
-
    - {media.map(attachment => { - const displayUrl = attachment.get('remote_url') || attachment.get('url'); - - return ( -
  • - {filename(displayUrl)} -
  • - ); - })} -
-
- ); - } - - return ( -
-
- -
- -
    - {media.map(attachment => { - const displayUrl = attachment.get('remote_url') || attachment.get('url'); - - return ( -
  • - {filename(displayUrl)} -
  • - ); - })} -
-
- ); - } - -} diff --git a/app/soapbox/components/attachment_list.tsx b/app/soapbox/components/attachment_list.tsx new file mode 100644 index 000000000..94c496819 --- /dev/null +++ b/app/soapbox/components/attachment_list.tsx @@ -0,0 +1,54 @@ +import React from 'react'; + +import Icon from 'soapbox/components/icon'; + +import type { Attachment as AttachmentEntity } from 'soapbox/types/entities'; + +const filename = (url: string) => url.split('/').pop()!.split('#')[0].split('?')[0]; + +interface IAttachmentList { + media: AttachmentEntity[], + compact?: boolean, +} + +const AttachmentList: React.FC = ({ media, compact }) => { + if (compact) { + return ( +
+
    + {media.map(attachment => { + const displayUrl = attachment.get('remote_url') || attachment.get('url'); + + return ( +
  • + {filename(displayUrl)} +
  • + ); + })} +
+
+ ); + } + + return ( +
+
+ +
+ +
    + {media.map(attachment => { + const displayUrl = attachment.get('remote_url') || attachment.get('url'); + + return ( +
  • + {filename(displayUrl)} +
  • + ); + })} +
+
+ ); +}; + +export default AttachmentList;