[Glitch] Display AttachmentList in timelines in compact style when media missing
Port 86a9de6753
to glitch-soc
This commit is contained in:
parent
837b3804bf
commit
3bc5452449
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
|
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
|
||||||
|
@ -8,10 +9,25 @@ export default class AttachmentList extends ImmutablePureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
media: ImmutablePropTypes.list.isRequired,
|
media: ImmutablePropTypes.list.isRequired,
|
||||||
|
compact: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
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 (
|
return (
|
||||||
<div className='attachment-list'>
|
<div className='attachment-list'>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import StatusHeader from './status_header';
|
||||||
import StatusIcons from './status_icons';
|
import StatusIcons from './status_icons';
|
||||||
import StatusContent from './status_content';
|
import StatusContent from './status_content';
|
||||||
import StatusActionBar from './status_action_bar';
|
import StatusActionBar from './status_action_bar';
|
||||||
|
import AttachmentList from './attachment_list';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { MediaGallery, Video } from 'flavours/glitch/util/async-components';
|
import { MediaGallery, Video } from 'flavours/glitch/util/async-components';
|
||||||
import { HotKeys } from 'react-hotkeys';
|
import { HotKeys } from 'react-hotkeys';
|
||||||
|
@ -311,7 +312,12 @@ export default class Status extends ImmutablePureComponent {
|
||||||
attachments = status.get('media_attachments');
|
attachments = status.get('media_attachments');
|
||||||
if (attachments.size > 0 && !muted) {
|
if (attachments.size > 0 && !muted) {
|
||||||
if (attachments.some(item => item.get('type') === 'unknown')) { // Media type is 'unknown'
|
if (attachments.some(item => item.get('type') === 'unknown')) { // Media type is 'unknown'
|
||||||
/* Do nothing */
|
media = (
|
||||||
|
<AttachmentList
|
||||||
|
compact
|
||||||
|
media={status.get('media_attachments')}
|
||||||
|
/>
|
||||||
|
);
|
||||||
} else if (attachments.getIn([0, 'type']) === 'video') { // Media type is 'video'
|
} else if (attachments.getIn([0, 'type']) === 'video') { // Media type is 'video'
|
||||||
const video = status.getIn(['media_attachments', 0]);
|
const video = status.getIn(['media_attachments', 0]);
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
margin-top: 14px;
|
margin-top: 14px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-list__icon {
|
&__icon {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
color: $ui-base-lighter-color;
|
color: $ui-base-lighter-color;
|
||||||
padding: 8px 18px;
|
padding: 8px 18px;
|
||||||
|
@ -22,9 +21,9 @@
|
||||||
.fa {
|
.fa {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment-list__list {
|
&__list {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
|
@ -46,6 +45,21 @@
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.compact {
|
||||||
|
border: 0;
|
||||||
|
margin-top: 4px;
|
||||||
|
|
||||||
|
.attachment-list__list {
|
||||||
|
padding: 0;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa {
|
||||||
|
color: $ui-base-lighter-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-editor {
|
.list-editor {
|
||||||
|
|
Loading…
Reference in New Issue