[Glitch] Display AttachmentList in timelines in compact style when media missing

Port 86a9de6753 to glitch-soc
This commit is contained in:
Thibaut Girka
2018-03-27 15:40:10 +02:00
parent 837b3804bf
commit 3bc5452449
3 changed files with 74 additions and 38 deletions

View File

@@ -1,5 +1,6 @@
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import ImmutablePureComponent from 'react-immutable-pure-component';
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
@@ -8,10 +9,25 @@ export default class AttachmentList extends ImmutablePureComponent {
static propTypes = {
media: ImmutablePropTypes.list.isRequired,
compact: PropTypes.bool,
};
render () {
const { media } = this.props;
const { media, compact } = this.props;
if (compact) {
return (
<div className='attachment-list compact'>
<ul className='attachment-list__list'>
{media.map(attachment => (
<li key={attachment.get('id')}>
<a href={attachment.get('remote_url')} target='_blank' rel='noopener'><i className='fa fa-link' /> {filename(attachment.get('remote_url'))}</a>
</li>
))}
</ul>
</div>
);
}
return (
<div className='attachment-list'>