Skip to content

Commit

Permalink
fix: reset unsaved controls changes on modal close
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani committed Sep 26, 2024
1 parent 04919cb commit 34e5053
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/events/listeners/header-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export default class HeaderListeners extends Listeners {

init() {
if (this._setup) {
this._viewInFocus == 'seek' && this._seek.init()
this._viewInFocus == 'fx' && this._reverb.init()
this._viewInFocus == 'eq' && this._equalizer.init()
this._viewInFocus == 'speed' && this._speed.init()
return
}

Expand All @@ -29,7 +31,19 @@ export default class HeaderListeners extends Listeners {
this._setup = true
}

#clearReverb() {
const reverb = this._store.getReverb() || 'none'
if (reverb == 'none') this._reverb.clearReverb()
}

#clearEqualizer() {
const equalizer = this._store.getEqualizer() || 'none'
if (equalizer == 'none') this._equalizer.clearEqualizer()
}

async hide() {
if (this._viewInFocus == 'fx') this.#clearReverb()
if (this._viewInFocus == 'eq') this.#clearEqualizer()
if (this._viewInFocus == 'speed') this._speed.clearCurrentSpeed()
this._hide()
}
Expand Down
2 changes: 2 additions & 0 deletions src/events/listeners/listeners.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { store } from '../../stores/data.js'
import Seek from '../../models/seek/seek.js'
import Speed from '../../models/speed/speed.js'
import { spotifyVideo } from '../../actions/overload.js'
Expand All @@ -7,6 +8,7 @@ import EqualizerController from '../../models/equalizer/equalizer-controller.js'

export default class Listeners {
constructor(songTracker) {
this._store = store
this._video = spotifyVideo.element
this._seek = new Seek()
this._speed = new Speed()
Expand Down
2 changes: 1 addition & 1 deletion src/models/reverb/reverb-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class ReverbController {
const { roomEffect, convolverEffect, presetSelection } = this.elements

if (effect == 'none') {
this.setValuesToNone()
this.clearReverb()
} else {
presetSelection.textContent = effect
const selectedElement = roomPresets.includes(effect) ? roomEffect : convolverEffect
Expand Down

0 comments on commit 34e5053

Please sign in to comment.