diff --git a/web/media/encrypted-multimedia.react.js b/web/media/encrypted-multimedia.react.js index 539cff8e3..692e21f4b 100644 --- a/web/media/encrypted-multimedia.react.js +++ b/web/media/encrypted-multimedia.react.js @@ -1,125 +1,134 @@ // @flow import invariant from 'invariant'; import * as React from 'react'; import 'react-circular-progressbar/dist/styles.css'; import { AlertCircle as AlertCircleIcon } from 'react-feather'; import type { Shape } from 'lib/types/core.js'; import type { EncryptedMediaType } from 'lib/types/media-types.js'; import { decryptMedia } from './encryption-utils.js'; import LoadableVideo from './loadable-video.react.js'; import css from './media.css'; import LoadingIndicator from '../loading-indicator.react.js'; type Props = { +holder: string, +encryptionKey: string, +type: EncryptedMediaType, - +thumbnailHolder: ?string, - +thumbnailEncryptionKey: ?string, + +thumbnailHolder?: ?string, + +thumbnailEncryptionKey?: ?string, +placeholderSrc?: ?string, + +multimediaClassName?: string, +elementStyle?: ?Shape, }; function EncryptedMultimedia(props: Props): React.Node { - const { holder, encryptionKey, placeholderSrc, elementStyle } = props; + const { + holder, + encryptionKey, + placeholderSrc, + elementStyle, + multimediaClassName, + } = props; const [source, setSource] = React.useState(null); const videoRef = React.useRef(null); React.useEffect(() => { let isMounted = true, uriToDispose; setSource(null); const loadDecrypted = async () => { const { result } = await decryptMedia(holder, encryptionKey); if (!isMounted) { return; } if (result.success) { const { uri } = result; setSource({ uri }); uriToDispose = uri; } else { setSource({ error: result.reason }); } }; loadDecrypted(); return () => { isMounted = false; if (uriToDispose) { URL.revokeObjectURL(uriToDispose); } }; }, [holder, encryptionKey]); // we need to update the video source when the source changes // because re-rendering the element wouldn't reload parent