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;

View file

@ -397,7 +397,7 @@ import { imageSize } from "image-size";
import prettyBytes from "pretty-bytes";
import RoomExport from "./RoomExport.vue";
import EmojiPicker from 'vue3-emoji-picker';
import emitter from 'tiny-emitter/instance';
const READ_RECEIPT_TIMEOUT = 5000; /* How long a message must have been visible before the read marker is updated */
const WINDOW_BUFFER_SIZE = 0.3; /** Relative window height of when we start paginating. Always keep this much loaded before and after our scroll position! */
@ -562,7 +562,7 @@ export default {
},
mounted() {
this.$root.$on('audio-playback-ended', this.audioPlaybackEnded);
emitter.on('audio-playback-ended', this.audioPlaybackEnded);
const container = this.chatContainer;
if (container) {
this.scrollPosition = new ScrollPosition(container);
@ -573,7 +573,7 @@ export default {
},
beforeDestroy() {
this.$root.$off('audio-playback-ended', this.audioPlaybackEnded);
emitter.off('audio-playback-ended', this.audioPlaybackEnded);
this.$audioPlayer.pause();
this.stopRRTimer();
if (this.retentionTimer) {