export default class PresetController { constructor(presetStore) { this.presetStore = presetStore; this.previousPreset = ""; this.currentPreset = ""; } getName() { return Object.keys(this.presetStore); } set(newPreset, currentAudioSource, currentAudioVolume) { let newPresetData = JSON.parse(JSON.stringify(this.presetStore[newPreset])); if (this.previousPreset) { if ( currentAudioSource && this.presetStore[this.previousPreset].audioOptions.source !== currentAudioSource ) { newPresetData.audioOptions.source = currentAudioSource; } if ( currentAudioVolume || (currentAudioVolume === 0 && this.presetStore[this.previousPreset].audioOptions.volume !== currentAudioVolume) ) { newPresetData.audioOptions.volume = currentAudioVolume; } } if (this.currentPreset) { this.previousPreset = this.currentPreset; } this.currentPreset = newPreset; return newPresetData; } }