Browse Source
Simplify first job running on DeviceInteractionStep
master
meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
1 changed files with
6 additions and
15 deletions
-
src/components/DeviceInteraction/DeviceInteractionStep.js
|
@ -55,23 +55,14 @@ class DeviceInteractionStep extends PureComponent< |
|
|
data: {}, |
|
|
data: {}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
constructor(props: Props) { |
|
|
|
|
|
super(props) |
|
|
|
|
|
const { isFirst } = this.props |
|
|
|
|
|
if (isFirst) { |
|
|
|
|
|
// cf: __IS_MOUNTED__THX_FOR_REMOVING_COMPONENTWILLMOUNT__
|
|
|
|
|
|
this.state.status = 'running' |
|
|
|
|
|
|
|
|
|
|
|
this.run() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
state = { |
|
|
state = { |
|
|
status: 'idle', |
|
|
status: this.props.isFirst ? 'running' : 'idle', |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
componentDidMount() { |
|
|
this.__IS_MOUNTED__THX_FOR_REMOVING_COMPONENTWILLMOUNT__ = true |
|
|
if (this.props.isFirst) { |
|
|
|
|
|
this.run() |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps: Props) { |
|
|
componentDidUpdate(prevProps: Props) { |
|
@ -103,7 +94,6 @@ class DeviceInteractionStep extends PureComponent< |
|
|
this._unmounted = true |
|
|
this._unmounted = true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
__IS_MOUNTED__THX_FOR_REMOVING_COMPONENTWILLMOUNT__ = false |
|
|
|
|
|
_unsubscribe = null |
|
|
_unsubscribe = null |
|
|
_unmounted = false |
|
|
_unmounted = false |
|
|
|
|
|
|
|
@ -122,8 +112,9 @@ class DeviceInteractionStep extends PureComponent< |
|
|
|
|
|
|
|
|
run = async () => { |
|
|
run = async () => { |
|
|
const { step, data } = this.props |
|
|
const { step, data } = this.props |
|
|
|
|
|
const { status } = this.state |
|
|
|
|
|
|
|
|
if (this.__IS_MOUNTED__THX_FOR_REMOVING_COMPONENTWILLMOUNT__) { |
|
|
if (status !== 'running') { |
|
|
this.setState({ status: 'running' }) |
|
|
this.setState({ status: 'running' }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|