about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-03-27 15:50:05 +0200
committerThibaut Girka <thib@sitedethib.com>2018-03-27 16:09:33 +0200
commit88790b91de64ad7848477a9edcbebbbe1adb5d13 (patch)
treecea93c6d89d9de7e21b0a005f7aa6ff70ea2ca74 /app/javascript/flavours/glitch
parent3bc5452449d492fd7fc9bba28a24acb877fc8dad (diff)
[Glitch] Display AttachmentList in notifications
Port 77406d3a092db48250a85984dde2f2cc81386146 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch')
-rw-r--r--app/javascript/flavours/glitch/components/attachment_list.js24
-rw-r--r--app/javascript/flavours/glitch/components/status.js10
2 files changed, 20 insertions, 14 deletions
diff --git a/app/javascript/flavours/glitch/components/attachment_list.js b/app/javascript/flavours/glitch/components/attachment_list.js
index ef937fb4c..b31d40b04 100644
--- a/app/javascript/flavours/glitch/components/attachment_list.js
+++ b/app/javascript/flavours/glitch/components/attachment_list.js
@@ -19,11 +19,15 @@ export default class AttachmentList extends ImmutablePureComponent {
       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>
-            ))}
+            {media.map(attachment => {
+              const displayUrl = attachment.get('remote_url') || attachment.get('url');
+
+              return (
+                <li key={attachment.get('id')}>
+                  <a href={displayUrl} target='_blank' rel='noopener'><i className='fa fa-link' /> {filename(displayUrl)}</a>
+                </li>
+              );
+            })}
           </ul>
         </div>
       );
@@ -36,11 +40,13 @@ export default class AttachmentList extends ImmutablePureComponent {
         </div>
 
         <ul className='attachment-list__list'>
-          {media.map(attachment =>
-            (<li key={attachment.get('id')}>
-              <a href={attachment.get('remote_url')} target='_blank' rel='noopener'>{filename(attachment.get('remote_url'))}</a>
+          const displayUrl = attachment.get('remote_url') || attachment.get('url');
+
+          {media.map(attachment => {
+            return (<li key={attachment.get('id')}>
+              <a href={displayUrl} target='_blank' rel='noopener'>{filename(displayUrl)}</a>
             </li>)
-          )}
+          })}
         </ul>
       </div>
     );
diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js
index 51f0f8884..2fcc44882 100644
--- a/app/javascript/flavours/glitch/components/status.js
+++ b/app/javascript/flavours/glitch/components/status.js
@@ -302,16 +302,16 @@ export default class Status extends ImmutablePureComponent {
       background = status.getIn(['account', 'header']);
     }
 
-    //  This handles our media attachments. Note that we don't show media on
-    //  muted (notification) statuses. If the media type is unknown, then we
-    //  simply ignore it.
+    //  This handles our media attachments.
+    //  If a media file is of unknwon type or if the status is muted
+    //  (notification), we show a list of links instead of embedded media.
 
     //  After we have generated our appropriate media element and stored it in
     //  `media`, we snatch the thumbnail to use as our `background` if media
     //  backgrounds for collapsed statuses are enabled.
     attachments = status.get('media_attachments');
-    if (attachments.size > 0 && !muted) {
-      if (attachments.some(item => item.get('type') === 'unknown')) {  //  Media type is 'unknown'
+    if (attachments.size > 0) {
+      if (muted || attachments.some(item => item.get('type') === 'unknown')) {
         media = (
           <AttachmentList
             compact