From 3bc5452449d492fd7fc9bba28a24acb877fc8dad Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 27 Mar 2018 15:40:10 +0200 Subject: [PATCH 1/2] [Glitch] Display AttachmentList in timelines in compact style when media missing Port 86a9de6753fc425b247699c7822bc8a5d49af043 to glitch-soc --- .../glitch/components/attachment_list.js | 18 +++- .../flavours/glitch/components/status.js | 8 +- .../glitch/styles/components/lists.scss | 86 +++++++++++-------- 3 files changed, 74 insertions(+), 38 deletions(-) diff --git a/app/javascript/flavours/glitch/components/attachment_list.js b/app/javascript/flavours/glitch/components/attachment_list.js index 3a28c70f3bb..ef937fb4cc7 100644 --- a/app/javascript/flavours/glitch/components/attachment_list.js +++ b/app/javascript/flavours/glitch/components/attachment_list.js @@ -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 ( +
+ +
+ ); + } return (
diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index 77477fe9531..51f0f888451 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -6,6 +6,7 @@ import StatusHeader from './status_header'; import StatusIcons from './status_icons'; import StatusContent from './status_content'; import StatusActionBar from './status_action_bar'; +import AttachmentList from './attachment_list'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { MediaGallery, Video } from 'flavours/glitch/util/async-components'; import { HotKeys } from 'react-hotkeys'; @@ -311,7 +312,12 @@ export default class Status extends ImmutablePureComponent { attachments = status.get('media_attachments'); if (attachments.size > 0 && !muted) { if (attachments.some(item => item.get('type') === 'unknown')) { // Media type is 'unknown' - /* Do nothing */ + media = ( + + ); } else if (attachments.getIn([0, 'type']) === 'video') { // Media type is 'video' const video = status.getIn(['media_attachments', 0]); diff --git a/app/javascript/flavours/glitch/styles/components/lists.scss b/app/javascript/flavours/glitch/styles/components/lists.scss index de0783b6d1d..85f416ceb52 100644 --- a/app/javascript/flavours/glitch/styles/components/lists.scss +++ b/app/javascript/flavours/glitch/styles/components/lists.scss @@ -5,45 +5,59 @@ border-radius: 4px; margin-top: 14px; overflow: hidden; -} -.attachment-list__icon { - flex: 0 0 auto; - color: $ui-base-lighter-color; - padding: 8px 18px; - cursor: default; - border-right: 1px solid lighten($ui-base-color, 8%); - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: 26px; - - .fa { - display: block; - } -} - -.attachment-list__list { - list-style: none; - padding: 4px 0; - padding-left: 8px; - display: flex; - flex-direction: column; - justify-content: center; - - li { - display: block; - padding: 4px 0; - } - - a { - text-decoration: none; + &__icon { + flex: 0 0 auto; color: $ui-base-lighter-color; - font-weight: 500; + padding: 8px 18px; + cursor: default; + border-right: 1px solid lighten($ui-base-color, 8%); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: 26px; - &:hover { - text-decoration: underline; + .fa { + display: block; + } + } + + &__list { + list-style: none; + padding: 4px 0; + padding-left: 8px; + display: flex; + flex-direction: column; + justify-content: center; + + li { + display: block; + padding: 4px 0; + } + + a { + text-decoration: none; + color: $ui-base-lighter-color; + font-weight: 500; + + &:hover { + text-decoration: underline; + } + } + } + + &.compact { + border: 0; + margin-top: 4px; + + .attachment-list__list { + padding: 0; + display: block; + } + + .fa { + color: $ui-base-lighter-color; } } } From 88790b91de64ad7848477a9edcbebbbe1adb5d13 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 27 Mar 2018 15:50:05 +0200 Subject: [PATCH 2/2] [Glitch] Display AttachmentList in notifications Port 77406d3a092db48250a85984dde2f2cc81386146 to glitch-soc --- .../glitch/components/attachment_list.js | 24 ++++++++++++------- .../flavours/glitch/components/status.js | 10 ++++---- 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 ef937fb4cc7..b31d40b0433 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 (
); @@ -36,11 +40,13 @@ export default class AttachmentList extends ImmutablePureComponent {
); diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index 51f0f888451..2fcc44882d4 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 = (