// Metro module 13593 (f13594). import AuthenticationStore from "../../stores/AuthenticationStore"; import MediaEngineStore from "../../stores/MediaEngineStore"; import LifecycleManager from "../../lib/LifecycleManager"; import Dispatcher from "../../Dispatcher"; class BaseSoundboardManager extends LifecycleManager { _playSound = () => {}; _stopAndClearSounds = () => {}; _handleToggleSelfDeafened = () => { if (MediaEngineStore.isDeaf()) { this._stopAndClearSounds(); } }; _handleSoundboardSoundReceived = ({ soundId, soundVolume, userId, channelId }) => { if (soundId != null && userId !== AuthenticationStore.getId()) { return this._playSound(soundId, soundVolume, userId, channelId); } }; _handleSoundboardSoundPlayLocally = ({ sound, channelId }) => this._playSound(sound.soundId, sound.volume, AuthenticationStore.getId(), channelId); _handleVoiceChannelSelect = () => { this._stopAndClearSounds(); }; _initialize() { Dispatcher.subscribe("VOICE_CHANNEL_EFFECT_SEND", this._handleSoundboardSoundReceived); Dispatcher.subscribe("GUILD_SOUNDBOARD_SOUND_PLAY_LOCALLY", this._handleSoundboardSoundPlayLocally); Dispatcher.subscribe("VOICE_CHANNEL_SELECT", this._handleVoiceChannelSelect); Dispatcher.subscribe("AUDIO_TOGGLE_SELF_DEAF", this._handleToggleSelfDeafened); } _terminate() { Dispatcher.unsubscribe("VOICE_CHANNEL_EFFECT_SEND", this._handleSoundboardSoundReceived); Dispatcher.unsubscribe("GUILD_SOUNDBOARD_SOUND_PLAY_LOCALLY", this._handleSoundboardSoundPlayLocally); Dispatcher.unsubscribe("VOICE_CHANNEL_SELECT", this._handleVoiceChannelSelect); Dispatcher.unsubscribe("AUDIO_TOGGLE_SELF_DEAF", this._handleToggleSelfDeafened); } } export default BaseSoundboardManager;