Skip to content

Commit

Permalink
fix: rerender only accepted images
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Apr 6, 2018
1 parent 3975c58 commit 2793704
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/static/components/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class State extends Component {
if (isErroredStatus(status)) {
elem = <StateError image={Boolean(image)} actual={actualPath} reason={reason}/>;
} else if (isSuccessStatus(status) || isUpdatedStatus(status) || (isIdleStatus(status) && expectedPath)) {
elem = <StateSuccess expected={expectedPath}/>;
elem = <StateSuccess status={status} expected={expectedPath} />;
} else if (isFailStatus(status)) {
elem = reason
? <StateError image={true} actual={actualPath} reason={reason}/>
Expand Down
3 changes: 1 addition & 2 deletions lib/static/components/state/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export default class Screenshot extends Component {
const url = this.props.imagePath
.split('/')
.map((item) => encodeURIComponent(item))
.join('/')
.concat(`?t=${Date.now()}`);
.join('/');

return (
<LazyLoad offsetVertical={800}>
Expand Down
13 changes: 12 additions & 1 deletion lib/static/components/state/state-success.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Screenshot from './screenshot';
import {isUpdatedStatus} from '../../../common-utils';

export default class StateSuccess extends Component {
static propTypes = {
status: PropTypes.string.isRequired,
expected: PropTypes.string.isRequired
}

render() {
const imagePath = isUpdatedStatus(this.props.status)
? addTimestamp(this.props.expected)
: this.props.expected;

return (
<div className="image-box__image">
<Screenshot imagePath={this.props.expected}/>
<Screenshot imagePath={imagePath}/>
</div>
);
}
}

// for prevent image caching
function addTimestamp(imagePath) {
return imagePath.concat(`?t=${Date.now()}`);
}

0 comments on commit 2793704

Please sign in to comment.