Display AttachmentList in timelines in compact style when media missing (#6680)

This commit is contained in:
Eugen Rochko 2018-03-08 04:54:26 +01:00 committed by GitHub
parent 83c982b458
commit 86a9de6753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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'>

View File

@ -7,6 +7,7 @@ import RelativeTimestamp from './relative_timestamp';
import DisplayName from './display_name';
import StatusContent from './status_content';
import StatusActionBar from './status_action_bar';
import AttachmentList from './attachment_list';
import { FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { MediaGallery, Video } from '../features/ui/util/async-components';
@ -179,7 +180,12 @@ export default class Status extends ImmutablePureComponent {
if (status.get('media_attachments').size > 0 && !this.props.muted) {
if (status.get('media_attachments').some(item => item.get('type') === 'unknown')) {
media = (
<AttachmentList
compact
media={status.get('media_attachments')}
/>
);
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
const video = status.getIn(['media_attachments', 0]);

View File

@ -4222,9 +4222,8 @@ a.status-card {
border-radius: 4px;
margin-top: 14px;
overflow: hidden;
}
.attachment-list__icon {
&__icon {
flex: 0 0 auto;
color: $ui-base-lighter-color;
padding: 8px 18px;
@ -4241,7 +4240,7 @@ a.status-card {
}
}
.attachment-list__list {
&__list {
list-style: none;
padding: 4px 0;
padding-left: 8px;
@ -4265,6 +4264,21 @@ a.status-card {
}
}
&.compact {
border: 0;
margin-top: 4px;
.attachment-list__list {
padding: 0;
display: block;
}
.fa {
color: $ui-base-lighter-color;
}
}
}
/* Media Gallery */
.media-gallery {
box-sizing: border-box;