import * as React from "react"; import { defensiveClone } from "../util"; import { t } from "../i18next_wrapper"; type ImgTag = React.HTMLProps; interface Props extends ImgTag { src: string; fallback: string; } type State = Partial<{ needsFallback: boolean }>; /** Like a normal ``, but it has a `fallback` URL if the image does not * load*/ export class FallbackImg extends React.Component { state: State = { needsFallback: false }; UNSAFE_componentWillReceiveProps(next: Props) { // Sorry. The webcam page needs live updates. tag was acting wonky. (next.src !== this.props.src) && this.setState({ needsFallback: false }); } fallback = () => { return

{t("Unable to load webcam feed.")}

; } dontFallback = () => { const imgProps: Props = defensiveClone(this.props); delete imgProps.fallback; const onError = () => this.setState({ needsFallback: true }); const splitSrc = this.props.src.split(" "); const displaySrc = () => { switch (splitSrc[0]) { case "iframe": return