[Glitch] Add option to disable blurhash previews
Port 3086c645fd
to glitch-soc
This commit is contained in:
parent
383136d9bb
commit
4175f13155
|
@ -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 'flavours/glitch/util/is_mobile';
|
import { isIOS } from 'flavours/glitch/util/is_mobile';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { autoPlayGif, displayMedia } from 'flavours/glitch/util/initial_state';
|
import { autoPlayGif, displayMedia, useBlurhash } from 'flavours/glitch/util/initial_state';
|
||||||
import { decode } from 'blurhash';
|
import { decode } from 'blurhash';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -101,6 +101,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 'flavours/glitch/util/fullscreen';
|
import { isFullscreen, requestFullscreen, exitFullscreen } from 'flavours/glitch/util/fullscreen';
|
||||||
import { displayMedia } from 'flavours/glitch/util/initial_state';
|
import { displayMedia, useBlurhash } from 'flavours/glitch/util/initial_state';
|
||||||
import { decode } from 'blurhash';
|
import { decode } from 'blurhash';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -312,7 +312,7 @@ export default class Video extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
_decode () {
|
_decode () {
|
||||||
if (!this.canvas) return;
|
if (!this.canvas || !useBlurhash) return;
|
||||||
|
|
||||||
const hash = this.props.blurhash;
|
const hash = this.props.blurhash;
|
||||||
const pixels = decode(hash, 32, 32);
|
const pixels = decode(hash, 32, 32);
|
||||||
|
|
|
@ -29,5 +29,6 @@ export const mascot = getMeta('mascot');
|
||||||
export const isStaff = getMeta('is_staff');
|
export const isStaff = getMeta('is_staff');
|
||||||
export const defaultContentType = getMeta('default_content_type');
|
export const defaultContentType = getMeta('default_content_type');
|
||||||
export const forceSingleColumn = getMeta('advanced_layout') === false;
|
export const forceSingleColumn = getMeta('advanced_layout') === false;
|
||||||
|
export const useBlurhash = getMeta('use_blurhash');
|
||||||
|
|
||||||
export default initialState;
|
export default initialState;
|
||||||
|
|
Reference in New Issue