diff --git a/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx b/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx index 09897c1634da8f..5f10936b60e97f 100644 --- a/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx +++ b/app/javascript/flavours/glitch/features/ui/components/audio_modal.jsx @@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { connect } from 'react-redux'; +import { getAverageFromBlurhash } from 'flavours/glitch/blurhash'; import Audio from 'flavours/glitch/features/audio'; import Footer from 'flavours/glitch/features/picture_in_picture/components/footer'; @@ -26,6 +27,18 @@ class AudioModal extends ImmutablePureComponent { onChangeBackgroundColor: PropTypes.func.isRequired, }; + componentDidMount () { + const { media, onChangeBackgroundColor } = this.props; + + const backgroundColor = getAverageFromBlurhash(media.get('blurhash')); + + onChangeBackgroundColor(backgroundColor || { r: 255, g: 255, b: 255 }); + } + + componentWillUnmount () { + this.props.onChangeBackgroundColor(null); + } + render () { const { media, status, accountStaticAvatar, onClose } = this.props; const options = this.props.options || {}; diff --git a/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx b/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx index 489e26a9092718..beb9ad3c8f7420 100644 --- a/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx +++ b/app/javascript/flavours/glitch/features/ui/components/video_modal.jsx @@ -37,6 +37,10 @@ class VideoModal extends ImmutablePureComponent { } } + componentWillUnmount () { + this.props.onChangeBackgroundColor(null); + } + render () { const { media, status, onClose } = this.props; const options = this.props.options || {};