Skip to content

Commit 1ded3bb

Browse files
authored
Change reported media attachments to always be hidden in admin UI (#12879)
Also: - Fix Mastodon logo not showing up in status embeds - Fix blurhash not being used in status embeds - Fix blurhash not being used in admin UI - Fix autoplay param not working correctly on status embeds
1 parent 709ca04 commit 1ded3bb

6 files changed

Lines changed: 25 additions & 11 deletions

File tree

app/javascript/mastodon/components/media_gallery.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Item extends React.PureComponent {
2323
onClick: PropTypes.func.isRequired,
2424
displayWidth: PropTypes.number,
2525
visible: PropTypes.bool.isRequired,
26+
autoplay: PropTypes.bool,
2627
};
2728

2829
static defaultProps = {
@@ -48,9 +49,13 @@ class Item extends React.PureComponent {
4849
}
4950
}
5051

52+
getAutoPlay() {
53+
return this.props.autoplay || autoPlayGif;
54+
}
55+
5156
hoverToPlay () {
5257
const { attachment } = this.props;
53-
return !autoPlayGif && attachment.get('type') === 'gifv';
58+
return !this.getAutoPlay() && attachment.get('type') === 'gifv';
5459
}
5560

5661
handleClick = (e) => {
@@ -201,7 +206,7 @@ class Item extends React.PureComponent {
201206
</a>
202207
);
203208
} else if (attachment.get('type') === 'gifv') {
204-
const autoPlay = !isIOS() && autoPlayGif;
209+
const autoPlay = !isIOS() && this.getAutoPlay();
205210

206211
thumbnail = (
207212
<div className={classNames('media-gallery__gifv', { autoplay: autoPlay })}>
@@ -248,6 +253,7 @@ class MediaGallery extends React.PureComponent {
248253
defaultWidth: PropTypes.number,
249254
cacheWidth: PropTypes.func,
250255
visible: PropTypes.bool,
256+
autoplay: PropTypes.bool,
251257
onToggleVisibility: PropTypes.func,
252258
};
253259

@@ -297,7 +303,7 @@ class MediaGallery extends React.PureComponent {
297303
}
298304

299305
render () {
300-
const { media, intl, sensitive, height, defaultWidth, standalone } = this.props;
306+
const { media, intl, sensitive, height, defaultWidth, standalone, autoplay } = this.props;
301307
const { visible } = this.state;
302308

303309
const width = this.state.width || defaultWidth;
@@ -320,9 +326,9 @@ class MediaGallery extends React.PureComponent {
320326
const uncached = media.every(attachment => attachment.get('type') === 'unknown');
321327

322328
if (standalone && this.isFullSizeEligible()) {
323-
children = <Item standalone onClick={this.handleClick} attachment={media.get(0)} displayWidth={width} visible={visible} />;
329+
children = <Item standalone autoplay={autoplay} onClick={this.handleClick} attachment={media.get(0)} displayWidth={width} visible={visible} />;
324330
} else {
325-
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} />);
331+
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} autoplay={autoplay} onClick={this.handleClick} attachment={attachment} index={i} size={size} displayWidth={width} visible={visible || uncached} />);
326332
}
327333

328334
if (uncached) {

app/views/admin/reports/_status.html.haml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
- unless status.proper.media_attachments.empty?
1515
- if status.proper.media_attachments.first.video?
1616
- video = status.proper.media_attachments.first
17-
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), sensitive: !current_account&.user&.show_all_media? && status.proper.sensitive? || current_account&.user&.hide_all_media?, width: 610, height: 343, inline: true, alt: video.description
17+
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), blurhash: video.blurhash, sensitive: status.proper.sensitive?, visible: false, width: 610, height: 343, inline: true, alt: video.description
18+
- elsif status.media_attachments.first.audio?
19+
- audio = status.proper.media_attachments.first
20+
= react_component :audio, src: audio.file.url(:original), height: 110, alt: audio.description, duration: audio.file.meta.dig(:original, :duration)
1821
- else
19-
= react_component :media_gallery, height: 343, sensitive: !current_account&.user&.show_all_media? && status.proper.sensitive? || current_account&.user&.hide_all_media?, 'autoPlayGif': current_account&.user&.setting_auto_play_gif, media: status.proper.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }
22+
= react_component :media_gallery, height: 343, sensitive: status.proper.sensitive?, visible: false, media: status.proper.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }
2023

2124
.detailed-status__meta
2225
= link_to ActivityPub::TagManager.instance.url_for(status), class: 'detailed-status__datetime', target: stream_link_target, rel: 'noopener noreferrer' do

app/views/layouts/admin.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- content_for :header_tags do
2+
= render_initial_state
23
= javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous'
34

45
- content_for :content do

app/views/layouts/embedded.html.haml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
= stylesheet_pack_tag Setting.default_settings['theme'], media: 'all'
1515
= javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous'
1616
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
17+
= render_initial_state
1718
= javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous'
1819
%body.embed
1920
= yield
21+
22+
%div{ style: 'display: none'}
23+
= render file: Rails.root.join('app', 'javascript', 'images', 'logo_transparent.svg')

app/views/statuses/_detailed_status.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
- if !status.media_attachments.empty?
3030
- if status.media_attachments.first.video?
3131
- video = status.media_attachments.first
32-
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), blurhash: video.blurhash, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 670, height: 380, detailed: true, inline: true, alt: video.description do
32+
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), blurhash: video.blurhash, sensitive: status.sensitive?, width: 670, height: 380, detailed: true, inline: true, alt: video.description do
3333
= render partial: 'statuses/attachment_list', locals: { attachments: status.media_attachments }
3434
- elsif status.media_attachments.first.audio?
3535
- audio = status.media_attachments.first
3636
= react_component :audio, src: audio.file.url(:original), height: 130, alt: audio.description, preload: true, duration: audio.file.meta.dig(:original, :duration) do
3737
= render partial: 'statuses/attachment_list', locals: { attachments: status.media_attachments }
3838
- else
39-
= react_component :media_gallery, height: 380, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, standalone: true, 'autoPlayGif': current_account&.user&.setting_auto_play_gif || autoplay, 'reduceMotion': current_account&.user&.setting_reduce_motion, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } do
39+
= react_component :media_gallery, height: 380, sensitive: status.sensitive?, standalone: true, autoplay: autoplay, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } do
4040
= render partial: 'statuses/attachment_list', locals: { attachments: status.media_attachments }
4141
- elsif status.preview_card
4242
= react_component :card, 'maxDescription': 160, card: ActiveModelSerializers::SerializableResource.new(status.preview_card, serializer: REST::PreviewCardSerializer).as_json

app/views/statuses/_simple_status.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
- if !status.media_attachments.empty?
3434
- if status.media_attachments.first.video?
3535
- video = status.media_attachments.first
36-
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), blurhash: video.blurhash, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 610, height: 343, inline: true, alt: video.description do
36+
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), blurhash: video.blurhash, sensitive: status.sensitive?, width: 610, height: 343, inline: true, alt: video.description do
3737
= render partial: 'statuses/attachment_list', locals: { attachments: status.media_attachments }
3838
- elsif status.media_attachments.first.audio?
3939
- audio = status.media_attachments.first
4040
= react_component :audio, src: audio.file.url(:original), height: 110, alt: audio.description, duration: audio.file.meta.dig(:original, :duration) do
4141
= render partial: 'statuses/attachment_list', locals: { attachments: status.media_attachments }
4242
- else
43-
= react_component :media_gallery, height: 343, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, 'autoPlayGif': current_account&.user&.setting_auto_play_gif || autoplay, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } do
43+
= react_component :media_gallery, height: 343, sensitive: status.sensitive?, autoplay: autoplay, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } do
4444
= render partial: 'statuses/attachment_list', locals: { attachments: status.media_attachments }
4545
- elsif status.preview_card
4646
= react_component :card, 'maxDescription': 160, card: ActiveModelSerializers::SerializableResource.new(status.preview_card, serializer: REST::PreviewCardSerializer).as_json

0 commit comments

Comments
 (0)