Skip to content

Commit

Permalink
[#180] Fix performance issues due to types
Browse files Browse the repository at this point in the history
  • Loading branch information
noahko96 committed Feb 24, 2022
1 parent a22dc8e commit c1a591e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/javascript/src/components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Player extends React.Component<PlayerProps, PlayerState> {
showItemsStats: false
}

timeout: number = 0
timeout: any = null

constructor(props: PlayerProps) {
super(props)
Expand Down Expand Up @@ -405,7 +405,7 @@ class Player extends React.Component<PlayerProps, PlayerState> {
let showItem = this.showIfItem(port)
let showStat = this.showIfStat(port)
let isTimer = this.isTimer(port)
if (isTimer && this.timeout == 0) {
if (isTimer && this.timeout == null) {
this.timeout = this.startTimer(port)
}
return !isTimer && showItem && showStat ? (
Expand Down Expand Up @@ -455,7 +455,7 @@ class Player extends React.Component<PlayerProps, PlayerState> {
return isTimer
}

private startTimer(port: DefaultPortModel): number {
private startTimer(port: DefaultPortModel): ReturnType<typeof setTimeout> {
const timeoutSeconds: number = get(this.props.portMeta as any, `${port.id}.timeoutSeconds`)
const that = this
return setTimeout(function() {that.updateScene(port)}, timeoutSeconds * 1000)
Expand Down Expand Up @@ -587,7 +587,7 @@ class Player extends React.Component<PlayerProps, PlayerState> {
private stopTimer() {
if (this.timeout) {
clearTimeout(this.timeout)
this.timeout = 0
this.timeout = null
}
}

Expand Down

0 comments on commit c1a591e

Please sign in to comment.