Skip to content

Commit

Permalink
fix: clear callback timeouts when page changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmaddock committed Jul 7, 2020
1 parent 881e5cf commit fa6cbd4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/metastream-app/src/components/lobby/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ class _VideoPlayer extends PureComponent<PrivateProps, IState> {
}

this.props.dispatch(updatePlaybackTimer())
this.cancelCallbacks()
}

private cancelCallbacks() {
this.onMediaPlaybackChange.cancel()
this.onMediaSeek.cancel()
this.onMediaVolumeChange.cancel()
Expand Down Expand Up @@ -578,6 +581,8 @@ class _VideoPlayer extends PureComponent<PrivateProps, IState> {

this.setState({ mediaReady: false })

this.cancelCallbacks()

if (this.mediaTimeout) clearTimeout(this.mediaTimeout)
this.mediaTimeout = setTimeout(this.onMediaTimeout, MEDIA_TIMEOUT_DURATION) as any

Expand Down

0 comments on commit fa6cbd4

Please sign in to comment.