1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

fix for image widget: first selected image is displayed immediately

This commit is contained in:
Laura Fuentes Grau 2020-05-19 17:47:45 +02:00
parent e396d722a1
commit 882febc12c

View file

@ -45,20 +45,16 @@ class WidgetImage extends React.Component {
let file = this.props.files.find(file => file.id === parseInt(this.props.widget.customProperties.file, 10));
if(file !== undefined){
if(this.state.file === undefined || (this.state.file.id !== file.id )){
if (file !== undefined) {
if (this.state.file === undefined || (this.state.file.id !== file.id)) {
// if file has changed, download new file
if (this.state.file !== undefined && this.state.file.id !== file.id){
AppDispatcher.dispatch({
type: 'files/start-download',
data: file.id,
token: this.props.token
});
}
// either first time update or file id has changed
this.setState({file:file})
AppDispatcher.dispatch({
type: 'files/start-download',
data: file.id,
token: this.props.token
});
this.setState({ file: file })
}
}