Add option to disable blurhash previews (#11188)
* Add option to disable blurhash previews * Update option text * Change options ordergh/stable
parent
915c619394
commit
3086c645fd
|
@ -54,6 +54,7 @@ class Settings::PreferencesController < Settings::BaseController
|
||||||
:setting_aggregate_reblogs,
|
:setting_aggregate_reblogs,
|
||||||
:setting_show_application,
|
:setting_show_application,
|
||||||
:setting_advanced_layout,
|
:setting_advanced_layout,
|
||||||
|
:setting_use_blurhash,
|
||||||
notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account),
|
notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account),
|
||||||
interactions: %i(must_be_follower must_be_following must_be_following_dm)
|
interactions: %i(must_be_follower must_be_following must_be_following_dm)
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import IconButton from './icon_button';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { isIOS } from '../is_mobile';
|
import { isIOS } from '../is_mobile';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { autoPlayGif, displayMedia } from '../initial_state';
|
import { autoPlayGif, displayMedia, useBlurhash } from '../initial_state';
|
||||||
import { decode } from 'blurhash';
|
import { decode } from 'blurhash';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -81,6 +81,8 @@ class Item extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
_decode () {
|
_decode () {
|
||||||
|
if (!useBlurhash) return;
|
||||||
|
|
||||||
const hash = this.props.attachment.get('blurhash');
|
const hash = this.props.attachment.get('blurhash');
|
||||||
const pixels = decode(hash, 32, 32);
|
const pixels = decode(hash, 32, 32);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { fromJS, is } from 'immutable';
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { isFullscreen, requestFullscreen, exitFullscreen } from '../ui/util/fullscreen';
|
import { isFullscreen, requestFullscreen, exitFullscreen } from '../ui/util/fullscreen';
|
||||||
import { displayMedia } from '../../initial_state';
|
import { displayMedia, useBlurhash } from '../../initial_state';
|
||||||
import Icon from 'mastodon/components/icon';
|
import Icon from 'mastodon/components/icon';
|
||||||
import { decode } from 'blurhash';
|
import { decode } from 'blurhash';
|
||||||
|
|
||||||
|
@ -298,6 +298,8 @@ class Video extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
_decode () {
|
_decode () {
|
||||||
|
if (!useBlurhash) return;
|
||||||
|
|
||||||
const hash = this.props.blurhash;
|
const hash = this.props.blurhash;
|
||||||
const pixels = decode(hash, 32, 32);
|
const pixels = decode(hash, 32, 32);
|
||||||
|
|
||||||
|
|
|
@ -20,5 +20,6 @@ export const mascot = getMeta('mascot');
|
||||||
export const profile_directory = getMeta('profile_directory');
|
export const profile_directory = getMeta('profile_directory');
|
||||||
export const isStaff = getMeta('is_staff');
|
export const isStaff = getMeta('is_staff');
|
||||||
export const forceSingleColumn = !getMeta('advanced_layout');
|
export const forceSingleColumn = !getMeta('advanced_layout');
|
||||||
|
export const useBlurhash = getMeta('use_blurhash');
|
||||||
|
|
||||||
export default initialState;
|
export default initialState;
|
||||||
|
|
|
@ -34,6 +34,7 @@ class UserSettingsDecorator
|
||||||
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
|
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
|
||||||
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
|
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
|
||||||
user.settings['advanced_layout'] = advanced_layout_preference if change?('setting_advanced_layout')
|
user.settings['advanced_layout'] = advanced_layout_preference if change?('setting_advanced_layout')
|
||||||
|
user.settings['use_blurhash'] = use_blurhash_preference if change?('setting_use_blurhash')
|
||||||
end
|
end
|
||||||
|
|
||||||
def merged_notification_emails
|
def merged_notification_emails
|
||||||
|
@ -112,6 +113,10 @@ class UserSettingsDecorator
|
||||||
boolean_cast_setting 'setting_advanced_layout'
|
boolean_cast_setting 'setting_advanced_layout'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def use_blurhash_preference
|
||||||
|
boolean_cast_setting 'setting_use_blurhash'
|
||||||
|
end
|
||||||
|
|
||||||
def boolean_cast_setting(key)
|
def boolean_cast_setting(key)
|
||||||
ActiveModel::Type::Boolean.new.cast(settings[key])
|
ActiveModel::Type::Boolean.new.cast(settings[key])
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,7 +106,7 @@ class User < ApplicationRecord
|
||||||
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
|
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
|
||||||
:reduce_motion, :system_font_ui, :noindex, :theme, :display_media, :hide_network,
|
:reduce_motion, :system_font_ui, :noindex, :theme, :display_media, :hide_network,
|
||||||
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
||||||
:advanced_layout, to: :settings, prefix: :setting, allow_nil: false
|
:advanced_layout, :use_blurhash, to: :settings, prefix: :setting, allow_nil: false
|
||||||
|
|
||||||
attr_reader :invite_code
|
attr_reader :invite_code
|
||||||
attr_writer :external
|
attr_writer :external
|
||||||
|
|
|
@ -32,6 +32,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
|
store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
|
||||||
store[:reduce_motion] = object.current_account.user.setting_reduce_motion
|
store[:reduce_motion] = object.current_account.user.setting_reduce_motion
|
||||||
store[:advanced_layout] = object.current_account.user.setting_advanced_layout
|
store[:advanced_layout] = object.current_account.user.setting_advanced_layout
|
||||||
|
store[:use_blurhash] = object.current_account.user.setting_use_blurhash
|
||||||
store[:is_staff] = object.current_account.user.staff?
|
store[:is_staff] = object.current_account.user.staff?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :setting_display_media, collection: ['default', 'show_all', 'hide_all'],label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label
|
= f.input :setting_display_media, collection: ['default', 'show_all', 'hide_all'],label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :setting_use_blurhash, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :setting_expand_spoilers, as: :boolean, wrapper: :with_label
|
= f.input :setting_expand_spoilers, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ en:
|
||||||
setting_hide_network: Who you follow and who follows you will not be shown on your profile
|
setting_hide_network: Who you follow and who follows you will not be shown on your profile
|
||||||
setting_noindex: Affects your public profile and status pages
|
setting_noindex: Affects your public profile and status pages
|
||||||
setting_show_application: The application you use to toot will be displayed in the detailed view of your toots
|
setting_show_application: The application you use to toot will be displayed in the detailed view of your toots
|
||||||
|
setting_use_blurhash: Gradients are based on the colors of the hidden visuals but obfuscate any details
|
||||||
username: Your username will be unique on %{domain}
|
username: Your username will be unique on %{domain}
|
||||||
whole_word: When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word
|
whole_word: When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word
|
||||||
featured_tag:
|
featured_tag:
|
||||||
|
@ -109,6 +110,7 @@ en:
|
||||||
setting_system_font_ui: Use system's default font
|
setting_system_font_ui: Use system's default font
|
||||||
setting_theme: Site theme
|
setting_theme: Site theme
|
||||||
setting_unfollow_modal: Show confirmation dialog before unfollowing someone
|
setting_unfollow_modal: Show confirmation dialog before unfollowing someone
|
||||||
|
setting_use_blurhash: Show colorful gradients for hidden media
|
||||||
severity: Severity
|
severity: Severity
|
||||||
type: Import type
|
type: Import type
|
||||||
username: Username
|
username: Username
|
||||||
|
|
|
@ -32,6 +32,7 @@ defaults: &defaults
|
||||||
theme: 'default'
|
theme: 'default'
|
||||||
aggregate_reblogs: true
|
aggregate_reblogs: true
|
||||||
advanced_layout: false
|
advanced_layout: false
|
||||||
|
use_blurhash: true
|
||||||
notification_emails:
|
notification_emails:
|
||||||
follow: false
|
follow: false
|
||||||
reblog: false
|
reblog: false
|
||||||
|
|
Reference in New Issue