Browse Source

Merge pull request #1787 from valpinkman/feat/skip-bootloader-screen

LL-832 skip 'restart in bootloader' if device is already in bootloader
gre-patch-1
Gaëtan Renaudeau 6 years ago
committed by GitHub
parent
commit
aaeb3da3c0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/components/SettingsPage/RepairDeviceButton.js

12
src/components/SettingsPage/RepairDeviceButton.js

@ -33,28 +33,38 @@ class RepairDeviceButton extends PureComponent<Props, State> {
progress: 0, progress: 0,
} }
componentWillUnmount() {
if (this.timeout) {
clearTimeout(this.timeout)
}
}
open = () => this.setState({ opened: true, error: null }) open = () => this.setState({ opened: true, error: null })
sub: * sub: *
timeout: *
close = () => { close = () => {
if (this.sub) this.sub.unsubscribe() if (this.sub) this.sub.unsubscribe()
if (this.timeout) clearTimeout(this.timeout)
this.setState({ opened: false, isLoading: false, error: null, progress: 0 }) this.setState({ opened: false, isLoading: false, error: null, progress: 0 })
} }
repair = (version = null) => { repair = (version = null) => {
if (this.state.isLoading) return if (this.state.isLoading) return
const { push } = this.props const { push } = this.props
this.setState({ isLoading: true }) this.timeout = setTimeout(() => this.setState({ isLoading: true }), 500)
this.sub = firmwareRepair.send({ version }).subscribe({ this.sub = firmwareRepair.send({ version }).subscribe({
next: patch => { next: patch => {
this.setState(patch) this.setState(patch)
}, },
error: error => { error: error => {
logger.critical(error) logger.critical(error)
if (this.timeout) clearTimeout(this.timeout)
this.setState({ error, isLoading: false, progress: 0 }) this.setState({ error, isLoading: false, progress: 0 })
}, },
complete: () => { complete: () => {
if (this.timeout) clearTimeout(this.timeout)
this.setState({ opened: false, isLoading: false, progress: 0 }, () => { this.setState({ opened: false, isLoading: false, progress: 0 }, () => {
push('/manager') push('/manager')
}) })

Loading…
Cancel
Save