Skip to content

Commit

Permalink
fix: Prevent overwriting error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Reder committed Sep 26, 2018
1 parent d0ab73e commit 9694e17
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/renderer/components/views/EmulatorView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class View extends React.PureComponent<EmulatorViewProps, EmulatorViewState> {

private timer: NodeJS.Timer | null = null

private timerTimeout: NodeJS.Timer | null = null

constructor (public props: EmulatorViewProps) {
super(props)
this.state = {
Expand All @@ -51,6 +53,9 @@ class View extends React.PureComponent<EmulatorViewProps, EmulatorViewState> {

public componentWillReceiveProps (nextProps: EmulatorViewProps) {
if (nextProps.error) {
if (this.timerTimeout) {
clearTimeout(this.timerTimeout)
}
this.setState({
loading: false,
warning: nextProps.error
Expand All @@ -64,8 +69,12 @@ class View extends React.PureComponent<EmulatorViewProps, EmulatorViewState> {
}

public componentWillUnmount (): void {
if (!this.timer) return
clearInterval(this.timer)
if (this.timer) {
clearInterval(this.timer)
}
if (this.timerTimeout) {
clearTimeout(this.timerTimeout)
}
this.mounted = false
}

Expand All @@ -85,7 +94,7 @@ class View extends React.PureComponent<EmulatorViewProps, EmulatorViewState> {
inGameChatEnabled: false
})
}, 50)
setTimeout(() => {
this.timerTimeout = setTimeout(() => {
if (!this.mounted) return
this.setState({
loading: false,
Expand Down

0 comments on commit 9694e17

Please sign in to comment.