Replace deprecated $on and $off with tiny-emitter

This commit is contained in:
N-Pex 2025-05-06 11:34:53 +02:00
parent 7a801f3ec3
commit 3b4d3f08f6
6 changed files with 21 additions and 18 deletions

View file

@ -87,6 +87,7 @@ import messageMixin from "./messages/messageMixin";
import util from "../plugins/utils";
import AuthedImage from "./AuthedImage.vue";
import clapping from "@/assets/sounds/clapping.mp3";
import emitter from 'tiny-emitter/instance';
export default {
mixins: [messageMixin],
@ -131,18 +132,18 @@ export default {
};
},
mounted() {
this.$root.$on('audio-playback-started', this.audioPlaybackStarted);
this.$root.$on('audio-playback-paused', this.audioPlaybackPaused);
this.$root.$on('audio-playback-ended', this.audioPlaybackEnded);
this.$root.$on('audio-playback-reaction', this.audioPlaybackReaction);
emitter.on('audio-playback-started', this.audioPlaybackStarted);
emitter.on('audio-playback-paused', this.audioPlaybackPaused);
emitter.on('audio-playback-ended', this.audioPlaybackEnded);
emitter.on('audio-playback-reaction', this.audioPlaybackReaction);
document.body.classList.add("dark");
this.$audioPlayer.setAutoplay(false);
},
beforeDestroy() {
this.$root.$off('audio-playback-started', this.audioPlaybackStarted);
this.$root.$off('audio-playback-paused', this.audioPlaybackPaused);
this.$root.$off('audio-playback-ended', this.audioPlaybackEnded);
this.$root.$off('audio-playback-reaction', this.audioPlaybackReaction);
emitter.off('audio-playback-started', this.audioPlaybackStarted);
emitter.off('audio-playback-paused', this.audioPlaybackPaused);
emitter.off('audio-playback-ended', this.audioPlaybackEnded);
emitter.off('audio-playback-reaction', this.audioPlaybackReaction);
document.body.classList.remove("dark");
this.$audioPlayer.removeListener(this._uid);
this.currentAudioEvent = null;