Skip to content

Commit ae1bb45

Browse files
Gargronhiyuki2578
authored andcommitted
Add "not available" label on unknown media attachments (mastodon#11715)
1 parent abb6a5e commit ae1bb45

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

app/javascript/mastodon/components/media_gallery.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,22 @@ class MediaGallery extends React.PureComponent {
315315
style.height = height;
316316
}
317317

318-
const size = media.take(4).size;
318+
const size = media.take(4).size;
319+
const uncached = media.every(attachment => attachment.get('type') === 'unknown');
319320

320321
if (this.isStandaloneEligible()) {
321322
children = <Item standalone onClick={this.handleClick} attachment={media.get(0)} displayWidth={width} visible={visible} />;
322323
} else {
323-
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} displayWidth={width} visible={visible} />);
324+
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} displayWidth={width} visible={visible || uncached} />);
324325
}
325326

326-
if (visible) {
327+
if (uncached) {
328+
spoilerButton = (
329+
<button type='button' disabled className='spoiler-button__overlay'>
330+
<span className='spoiler-button__overlay__label'><FormattedMessage id='status.uncached_media_warning' defaultMessage='Not available' /></span>
331+
</button>
332+
);
333+
} else if (visible) {
327334
spoilerButton = <IconButton title={intl.formatMessage(messages.toggle_visible)} icon='eye-slash' overlay onClick={this.handleOpen} />;
328335
} else {
329336
spoilerButton = (
@@ -335,7 +342,7 @@ class MediaGallery extends React.PureComponent {
335342

336343
return (
337344
<div className='media-gallery' style={style} ref={this.handleRef}>
338-
<div className={classNames('spoiler-button', { 'spoiler-button--minified': visible })}>
345+
<div className={classNames('spoiler-button', { 'spoiler-button--minified': visible && !uncached })}>
339346
{spoilerButton}
340347
</div>
341348

app/javascript/styles/mastodon/components.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,6 +3477,14 @@ a.status-card.compact:hover {
34773477
background: rgba($base-overlay-background, 0.8);
34783478
}
34793479
}
3480+
3481+
&:disabled {
3482+
cursor: not-allowed;
3483+
3484+
.spoiler-button__overlay__label {
3485+
background: rgba($base-overlay-background, 0.5);
3486+
}
3487+
}
34803488
}
34813489
}
34823490

0 commit comments

Comments
 (0)