[Glitch] Display AttachmentList in notifications

Port 77406d3a09 to glitch-soc
This commit is contained in:
Thibaut Girka 2018-03-27 15:50:05 +02:00
parent 3bc5452449
commit 88790b91de
2 changed files with 20 additions and 14 deletions

View File

@ -19,11 +19,15 @@ export default class AttachmentList extends ImmutablePureComponent {
return ( return (
<div className='attachment-list compact'> <div className='attachment-list compact'>
<ul className='attachment-list__list'> <ul className='attachment-list__list'>
{media.map(attachment => ( {media.map(attachment => {
<li key={attachment.get('id')}> const displayUrl = attachment.get('remote_url') || attachment.get('url');
<a href={attachment.get('remote_url')} target='_blank' rel='noopener'><i className='fa fa-link' /> {filename(attachment.get('remote_url'))}</a>
</li> return (
))} <li key={attachment.get('id')}>
<a href={displayUrl} target='_blank' rel='noopener'><i className='fa fa-link' /> {filename(displayUrl)}</a>
</li>
);
})}
</ul> </ul>
</div> </div>
); );
@ -36,11 +40,13 @@ export default class AttachmentList extends ImmutablePureComponent {
</div> </div>
<ul className='attachment-list__list'> <ul className='attachment-list__list'>
{media.map(attachment => const displayUrl = attachment.get('remote_url') || attachment.get('url');
(<li key={attachment.get('id')}>
<a href={attachment.get('remote_url')} target='_blank' rel='noopener'>{filename(attachment.get('remote_url'))}</a> {media.map(attachment => {
return (<li key={attachment.get('id')}>
<a href={displayUrl} target='_blank' rel='noopener'>{filename(displayUrl)}</a>
</li>) </li>)
)} })}
</ul> </ul>
</div> </div>
); );

View File

@ -302,16 +302,16 @@ export default class Status extends ImmutablePureComponent {
background = status.getIn(['account', 'header']); background = status.getIn(['account', 'header']);
} }
// This handles our media attachments. Note that we don't show media on // This handles our media attachments.
// muted (notification) statuses. If the media type is unknown, then we // If a media file is of unknwon type or if the status is muted
// simply ignore it. // (notification), we show a list of links instead of embedded media.
// After we have generated our appropriate media element and stored it in // After we have generated our appropriate media element and stored it in
// `media`, we snatch the thumbnail to use as our `background` if media // `media`, we snatch the thumbnail to use as our `background` if media
// backgrounds for collapsed statuses are enabled. // backgrounds for collapsed statuses are enabled.
attachments = status.get('media_attachments'); attachments = status.get('media_attachments');
if (attachments.size > 0 && !muted) { if (attachments.size > 0) {
if (attachments.some(item => item.get('type') === 'unknown')) { // Media type is 'unknown' if (muted || attachments.some(item => item.get('type') === 'unknown')) {
media = ( media = (
<AttachmentList <AttachmentList
compact compact