Commit 882febc1 authored by Laura Fuentes Grau's avatar Laura Fuentes Grau

fix for image widget: first selected image is displayed immediately

parent e396d722
......@@ -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 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})
if (file !== undefined) {
if (this.state.file === undefined || (this.state.file.id !== file.id)) {
AppDispatcher.dispatch({
type: 'files/start-download',
data: file.id,
token: this.props.token
});
this.setState({ file: file })
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment