Changeset View
Changeset View
Standalone View
Standalone View
native/media/multimedia.react.js
Show All 24 Lines | |||||
}; | }; | ||||
class Multimedia extends React.PureComponent<Props, State> { | class Multimedia extends React.PureComponent<Props, State> { | ||||
static defaultProps = { | static defaultProps = { | ||||
spinnerColor: 'black', | spinnerColor: 'black', | ||||
}; | }; | ||||
constructor(props: Props) { | constructor(props: Props) { | ||||
super(props); | super(props); | ||||
invariant( | |||||
props.mediaInfo.type === 'photo' || props.mediaInfo.type === 'video', | |||||
'<Multimedia> supports only unencrypted images and videos', | |||||
); | |||||
this.state = { | this.state = { | ||||
currentURI: | currentURI: | ||||
props.mediaInfo.type === 'video' | props.mediaInfo.type === 'video' | ||||
? props.mediaInfo.thumbnailURI | ? props.mediaInfo.thumbnailURI | ||||
: props.mediaInfo.uri, | : props.mediaInfo.uri, | ||||
departingURI: null, | departingURI: null, | ||||
}; | }; | ||||
} | } | ||||
Show All 14 Lines | componentWillUnmount() { | ||||
inputState.reportURIDisplayed(currentURI, false); | inputState.reportURIDisplayed(currentURI, false); | ||||
if (departingURI) { | if (departingURI) { | ||||
inputState.reportURIDisplayed(departingURI, false); | inputState.reportURIDisplayed(departingURI, false); | ||||
} | } | ||||
} | } | ||||
componentDidUpdate(prevProps: Props, prevState: State) { | componentDidUpdate(prevProps: Props, prevState: State) { | ||||
const { inputState } = this; | const { inputState } = this; | ||||
invariant( | |||||
this.props.mediaInfo.type === 'photo' || | |||||
this.props.mediaInfo.type === 'video', | |||||
'<Multimedia> supports only unencrypted photos and videos', | |||||
); | |||||
const newURI = | const newURI = | ||||
this.props.mediaInfo.type === 'video' | this.props.mediaInfo.type === 'video' | ||||
? this.props.mediaInfo.thumbnailURI | ? this.props.mediaInfo.thumbnailURI | ||||
: this.props.mediaInfo.uri; | : this.props.mediaInfo.uri; | ||||
const oldURI = this.state.currentURI; | const oldURI = this.state.currentURI; | ||||
if (newURI !== oldURI) { | if (newURI !== oldURI) { | ||||
inputState.reportURIDisplayed(newURI, true); | inputState.reportURIDisplayed(newURI, true); | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |