Skip to content

Commit

Permalink
[ONC-17] Remove hotkeys on unmount of playbar to prevent double-trigg…
Browse files Browse the repository at this point in the history
…ers (#7654)
  • Loading branch information
schottra authored Feb 20, 2024
1 parent f6b21ac commit 49ff569
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/web/src/components/play-bar/desktop/PlayBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
playbackRateValueMap
} from '@audius/common/store'
import { Genre } from '@audius/common/utils'
import { setupHotkeys } from '@audius/harmony'
import { removeHotkeys, setupHotkeys } from '@audius/harmony'
import { Scrubber } from '@audius/stems'
import { push as pushRoute } from 'connected-react-router'
import { connect } from 'react-redux'
Expand Down Expand Up @@ -85,11 +85,12 @@ class PlayBar extends Component {
initialVolume: null,
mediaKey: 0
}
this.hotkeysHook = null
this.seekInterval = null
}

componentDidMount() {
setupHotkeys(
this.hotkeysHook = setupHotkeys(
{
32 /* space */: this.togglePlay,
37 /* left arrow */: this.onPrevious,
Expand Down Expand Up @@ -134,6 +135,7 @@ class PlayBar extends Component {

componentWillUnmount() {
clearInterval(this.seekInterval)
removeHotkeys(this.hotkeysHook)
}

goToTrackPage = () => {
Expand Down

0 comments on commit 49ff569

Please sign in to comment.