mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-23 07:14:10 +00:00
Add preference to always display sensitive media (#6448)
This commit is contained in:
parent
1167c6dbf8
commit
76f3d5d16b
|
@ -39,6 +39,7 @@ class Settings::PreferencesController < ApplicationController
|
|||
:setting_boost_modal,
|
||||
:setting_delete_modal,
|
||||
:setting_auto_play_gif,
|
||||
:setting_display_sensitive_media,
|
||||
:setting_reduce_motion,
|
||||
:setting_system_font_ui,
|
||||
:setting_noindex,
|
||||
|
|
|
@ -6,7 +6,7 @@ import IconButton from './icon_button';
|
|||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||
import { isIOS } from '../is_mobile';
|
||||
import classNames from 'classnames';
|
||||
import { autoPlayGif } from '../initial_state';
|
||||
import { autoPlayGif, displaySensitiveMedia } from '../initial_state';
|
||||
|
||||
const messages = defineMessages({
|
||||
toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' },
|
||||
|
@ -187,7 +187,7 @@ export default class MediaGallery extends React.PureComponent {
|
|||
};
|
||||
|
||||
state = {
|
||||
visible: !this.props.sensitive,
|
||||
visible: !this.props.sensitive || displaySensitiveMedia,
|
||||
};
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|||
import { throttle } from 'lodash';
|
||||
import classNames from 'classnames';
|
||||
import { isFullscreen, requestFullscreen, exitFullscreen } from '../ui/util/fullscreen';
|
||||
import { displaySensitiveMedia } from '../../initial_state';
|
||||
|
||||
const messages = defineMessages({
|
||||
play: { id: 'video.play', defaultMessage: 'Play' },
|
||||
|
@ -107,7 +108,7 @@ export default class Video extends React.PureComponent {
|
|||
fullscreen: false,
|
||||
hovered: false,
|
||||
muted: false,
|
||||
revealed: !this.props.sensitive,
|
||||
revealed: !this.props.sensitive || displaySensitiveMedia,
|
||||
};
|
||||
|
||||
setPlayerRef = c => {
|
||||
|
|
|
@ -5,6 +5,7 @@ const getMeta = (prop) => initialState && initialState.meta && initialState.meta
|
|||
|
||||
export const reduceMotion = getMeta('reduce_motion');
|
||||
export const autoPlayGif = getMeta('auto_play_gif');
|
||||
export const displaySensitiveMedia = getMeta('display_sensitive_media');
|
||||
export const unfollowModal = getMeta('unfollow_modal');
|
||||
export const boostModal = getMeta('boost_modal');
|
||||
export const deleteModal = getMeta('delete_modal');
|
||||
|
|
|
@ -23,6 +23,7 @@ class UserSettingsDecorator
|
|||
user.settings['boost_modal'] = boost_modal_preference if change?('setting_boost_modal')
|
||||
user.settings['delete_modal'] = delete_modal_preference if change?('setting_delete_modal')
|
||||
user.settings['auto_play_gif'] = auto_play_gif_preference if change?('setting_auto_play_gif')
|
||||
user.settings['display_sensitive_media'] = display_sensitive_media_preference if change?('setting_display_sensitive_media')
|
||||
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
|
||||
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
|
||||
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
|
||||
|
@ -65,6 +66,10 @@ class UserSettingsDecorator
|
|||
boolean_cast_setting 'setting_auto_play_gif'
|
||||
end
|
||||
|
||||
def display_sensitive_media_preference
|
||||
boolean_cast_setting 'setting_display_sensitive_media'
|
||||
end
|
||||
|
||||
def reduce_motion_preference
|
||||
boolean_cast_setting 'setting_reduce_motion'
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ class User < ApplicationRecord
|
|||
has_many :session_activations, dependent: :destroy
|
||||
|
||||
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
|
||||
:reduce_motion, :system_font_ui, :noindex, :theme,
|
||||
:reduce_motion, :system_font_ui, :noindex, :theme, :display_sensitive_media,
|
||||
to: :settings, prefix: :setting, allow_nil: false
|
||||
|
||||
attr_accessor :invite_code
|
||||
|
|
|
@ -25,6 +25,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
|||
store[:boost_modal] = object.current_account.user.setting_boost_modal
|
||||
store[:delete_modal] = object.current_account.user.setting_delete_modal
|
||||
store[:auto_play_gif] = object.current_account.user.setting_auto_play_gif
|
||||
store[:display_sensitive_media] = object.current_account.user.setting_display_sensitive_media
|
||||
store[:reduce_motion] = object.current_account.user.setting_reduce_motion
|
||||
end
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
.fields-group
|
||||
= f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label
|
||||
= f.input :setting_display_sensitive_media, as: :boolean, wrapper: :with_label
|
||||
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
|
||||
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
- if !status.media_attachments.empty?
|
||||
- if status.media_attachments.first.video?
|
||||
- video = status.media_attachments.first
|
||||
%div{ data: { component: 'Video', props: Oj.dump(src: video.file.url(:original), preview: video.file.url(:small), sensitive: status.sensitive?, width: 670, height: 380, detailed: true) }}
|
||||
%div{ data: { component: 'Video', props: Oj.dump(src: video.file.url(:original), preview: video.file.url(:small), sensitive: status.sensitive? && !current_account&.user&.setting_display_sensitive_media, width: 670, height: 380, detailed: true) }}
|
||||
- else
|
||||
%div{ data: { component: 'MediaGallery', props: Oj.dump(height: 380, sensitive: status.sensitive?, standalone: true, 'autoPlayGif': current_account&.user&.setting_auto_play_gif, 'reduceMotion': current_account&.user&.setting_reduce_motion, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }) }}
|
||||
%div{ data: { component: 'MediaGallery', props: Oj.dump(height: 380, sensitive: status.sensitive? && !current_account&.user&.setting_display_sensitive_media, standalone: true, 'autoPlayGif': current_account&.user&.setting_auto_play_gif, 'reduceMotion': current_account&.user&.setting_reduce_motion, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }) }}
|
||||
- elsif status.preview_cards.first
|
||||
%div{ data: { component: 'Card', props: Oj.dump('maxDescription': 160, card: ActiveModelSerializers::SerializableResource.new(status.preview_cards.first, serializer: REST::PreviewCardSerializer).as_json) }}
|
||||
|
||||
|
|
|
@ -23,6 +23,6 @@
|
|||
- unless status.media_attachments.empty?
|
||||
- if status.media_attachments.first.video?
|
||||
- video = status.media_attachments.first
|
||||
%div{ data: { component: 'Video', props: Oj.dump(src: video.file.url(:original), preview: video.file.url(:small), sensitive: status.sensitive?, width: 610, height: 343) }}
|
||||
%div{ data: { component: 'Video', props: Oj.dump(src: video.file.url(:original), preview: video.file.url(:small), sensitive: status.sensitive? && !current_account&.user&.setting_display_sensitive_media, width: 610, height: 343) }}
|
||||
- else
|
||||
%div{ data: { component: 'MediaGallery', props: Oj.dump(height: 343, sensitive: status.sensitive?, 'autoPlayGif': current_account&.user&.setting_auto_play_gif, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }) }}
|
||||
%div{ data: { component: 'MediaGallery', props: Oj.dump(height: 343, sensitive: status.sensitive? && !current_account&.user&.setting_display_sensitive_media, 'autoPlayGif': current_account&.user&.setting_auto_play_gif, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }) }}
|
||||
|
|
|
@ -45,6 +45,7 @@ en:
|
|||
setting_default_privacy: Post privacy
|
||||
setting_default_sensitive: Always mark media as sensitive
|
||||
setting_delete_modal: Show confirmation dialog before deleting a toot
|
||||
setting_display_sensitive_media: Always show media marked as sensitive
|
||||
setting_noindex: Opt-out of search engine indexing
|
||||
setting_reduce_motion: Reduce motion in animations
|
||||
setting_system_font_ui: Use system's default font
|
||||
|
|
|
@ -24,6 +24,7 @@ defaults: &defaults
|
|||
boost_modal: false
|
||||
delete_modal: true
|
||||
auto_play_gif: false
|
||||
display_sensitive_media: false
|
||||
reduce_motion: false
|
||||
system_font_ui: false
|
||||
noindex: false
|
||||
|
|
Loading…
Reference in a new issue