From a95f8271beba85ead81487f6e7c4ba372d4b454c Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sat, 14 Apr 2018 19:00:30 +0200 Subject: [PATCH] Revert some glitch-specific refactoring In order to keep my sanity when porting changes between glitch-soc and upstream. --- .../glitch/components/media_gallery.js | 82 +++++++------------ 1 file changed, 29 insertions(+), 53 deletions(-) diff --git a/app/javascript/flavours/glitch/components/media_gallery.js b/app/javascript/flavours/glitch/components/media_gallery.js index 309308d25..a2219378e 100644 --- a/app/javascript/flavours/glitch/components/media_gallery.js +++ b/app/javascript/flavours/glitch/components/media_gallery.js @@ -225,21 +225,35 @@ export default class MediaGallery extends React.PureComponent { this.props.onOpenMedia(this.props.media, index); } + isStandaloneEligible() { + const { media, standalone } = this.props; + return standalone && media.size === 1 && media.getIn([0, 'meta', 'small', 'aspect']); + } + render () { - const { - handleClick, - handleOpen, - } = this; - const { - fullwidth, - intl, - letterbox, - media, - sensitive, - standalone, - } = this.props; + const { media, intl, sensitive, letterbox, fullwidth } = this.props; const { visible } = this.state; const size = media.take(4).size; + + let children; + + if (!visible) { + let warning = ; + + children = ( + + ); + } else { + if (this.isStandaloneEligible()) { + children = ; + } else { + children = media.take(4).map((attachment, i) => ); + } + } + const computedClass = classNames('media-gallery', `size-${size}`, { 'full-width': fullwidth }); return ( @@ -248,7 +262,7 @@ export default class MediaGallery extends React.PureComponent {
@@ -259,46 +273,8 @@ export default class MediaGallery extends React.PureComponent { ) : null}
) : null} - {function () { - switch (true) { - case !visible: - return ( - - ); - case standalone && media.size === 1 && !!media.getIn([0, 'meta', 'small', 'aspect']): - return ( - - ); - default: - return media.take(4).map( - (attachment, i) => ( - - ) - ); - } - }()} + + {children} ); }