Skip to content

Commit 9b5f073

Browse files
GargronClearlyClaire
authored andcommitted
[Glitch] Change design of media tab on profiles in web UI
Port 89df27a to glitch-soc Signed-off-by: Claire <[email protected]>
1 parent 157ecf2 commit 9b5f073

File tree

9 files changed

+320
-237
lines changed

9 files changed

+320
-237
lines changed

app/javascript/flavours/glitch/components/media_gallery.jsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
1111
import { debounce } from 'lodash';
1212

1313
import { Blurhash } from 'flavours/glitch/components/blurhash';
14+
import { formatTime } from 'flavours/glitch/features/video';
1415

1516
import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state';
1617

@@ -58,7 +59,7 @@ class Item extends PureComponent {
5859

5960
hoverToPlay () {
6061
const { attachment } = this.props;
61-
return !this.getAutoPlay() && attachment.get('type') === 'gifv';
62+
return !this.getAutoPlay() && ['gifv', 'video'].includes(attachment.get('type'));
6263
}
6364

6465
handleClick = (e) => {
@@ -152,10 +153,15 @@ class Item extends PureComponent {
152153
/>
153154
</a>
154155
);
155-
} else if (attachment.get('type') === 'gifv') {
156+
} else if (['gifv', 'video'].includes(attachment.get('type'))) {
156157
const autoPlay = this.getAutoPlay();
158+
const duration = attachment.getIn(['meta', 'original', 'duration']);
157159

158-
badges.push(<span key='gif' className='media-gallery__gifv__label'>GIF</span>);
160+
if (attachment.get('type') === 'gifv') {
161+
badges.push(<span key='gif' className='media-gallery__gifv__label'>GIF</span>);
162+
} else {
163+
badges.push(<span key='video' className='media-gallery__gifv__label'>{formatTime(Math.floor(duration))}</span>);
164+
}
159165

160166
thumbnail = (
161167
<div className={classNames('media-gallery__gifv', { autoplay: autoPlay })}>
@@ -169,6 +175,7 @@ class Item extends PureComponent {
169175
onClick={this.handleClick}
170176
onMouseEnter={this.handleMouseEnter}
171177
onMouseLeave={this.handleMouseLeave}
178+
onLoadedData={this.handleImageLoad}
172179
autoPlay={autoPlay}
173180
playsInline
174181
loop

app/javascript/flavours/glitch/components/status.jsx

+21-21
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,27 @@ class Status extends ImmutablePureComponent {
648648
media={status.get('media_attachments')}
649649
/>,
650650
);
651+
} else if (['image', 'gifv'].includes(status.getIn(['media_attachments', 0, 'type'])) || status.get('media_attachments').size > 1) {
652+
media.push(
653+
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
654+
{Component => (
655+
<Component
656+
media={attachments}
657+
lang={language}
658+
sensitive={status.get('sensitive')}
659+
letterbox={settings.getIn(['media', 'letterbox'])}
660+
fullwidth={!rootId && settings.getIn(['media', 'fullwidth'])}
661+
hidden={isCollapsed || !isExpanded}
662+
onOpenMedia={this.handleOpenMedia}
663+
cacheWidth={this.props.cacheMediaWidth}
664+
defaultWidth={this.props.cachedMediaWidth}
665+
visible={this.state.showMedia}
666+
onToggleVisibility={this.handleToggleMediaVisibility}
667+
/>
668+
)}
669+
</Bundle>,
670+
);
671+
mediaIcons.push('picture-o');
651672
} else if (attachments.getIn([0, 'type']) === 'audio') {
652673
const attachment = status.getIn(['media_attachments', 0]);
653674
const description = attachment.getIn(['translation', 'description']) || attachment.get('description');
@@ -703,27 +724,6 @@ class Status extends ImmutablePureComponent {
703724
</Bundle>,
704725
);
705726
mediaIcons.push('video-camera');
706-
} else { // Media type is 'image' or 'gifv'
707-
media.push(
708-
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
709-
{Component => (
710-
<Component
711-
media={attachments}
712-
lang={language}
713-
sensitive={status.get('sensitive')}
714-
letterbox={settings.getIn(['media', 'letterbox'])}
715-
fullwidth={!rootId && settings.getIn(['media', 'fullwidth'])}
716-
hidden={isCollapsed || !isExpanded}
717-
onOpenMedia={this.handleOpenMedia}
718-
cacheWidth={this.props.cacheMediaWidth}
719-
defaultWidth={this.props.cachedMediaWidth}
720-
visible={this.state.showMedia}
721-
onToggleVisibility={this.handleToggleMediaVisibility}
722-
/>
723-
)}
724-
</Bundle>,
725-
);
726-
mediaIcons.push('picture-o');
727727
}
728728

729729
if (!status.get('sensitive') && !(status.get('spoiler_text').length > 0) && settings.getIn(['collapsed', 'backgrounds', 'preview_images'])) {

app/javascript/flavours/glitch/features/account_gallery/components/media_item.jsx

-158
This file was deleted.

0 commit comments

Comments
 (0)