diff --git a/components/MessagePane.vue b/components/MessagePane.vue index d0706ef..f83338e 100644 --- a/components/MessagePane.vue +++ b/components/MessagePane.vue @@ -235,7 +235,7 @@ export default { if (!conversationDiv) throw new Error('wtf'); conversationDiv.scrollTo(0, conversationDiv.scrollHeight); }, - typing(event: KeyboardEvent) { + async typing(event: KeyboardEvent) { const { $io } = useNuxtApp(); const specialKeys = [ @@ -252,7 +252,7 @@ export default { return; } - $io.emit('typing', this.channel.id); + (await $io).emit('typing', this.channel.id); }, mouseEnter() { document.body.addEventListener('keydown', this.keyPressed, false); @@ -344,14 +344,14 @@ export default { this.search.show = false; this.$refs.messageBox.focus(); }, - listenToWebsocket(conversationDiv: HTMLElement) { - const { $io } = useNuxtApp(); + async listenToWebsocket(conversationDiv: HTMLElement) { + let { $io } = useNuxtApp(); - $io.removeAllListeners(); + (await $io).removeAllListeners(); - $io.on(`message-${this.channel.id}`, (ev: { message: IMessage, deleted?: boolean }) => { + (await $io).on(`message-${this.channel.id}`, (ev: { message: IMessage, deleted?: boolean }) => { let { message, deleted } = ev; - + if (deleted) { useActiveStore().removeMessage(message.id); return; @@ -384,7 +384,7 @@ export default { }); let timeout: NodeJS.Timeout; - $io.on(`typing-${this.channel.id}`, (ev: string) => { + (await $io).on(`typing-${this.channel.id}`, (ev: string) => { if (ev === this.user?.username) return; clearTimeout(timeout); timeout = setTimeout(() => { diff --git a/pages/channel/[channelId].vue b/pages/channel/[channelId].vue index 7d397f2..22a3507 100644 --- a/pages/channel/[channelId].vue +++ b/pages/channel/[channelId].vue @@ -75,10 +75,10 @@ export default { } }; }, - mounted() { + async mounted() { const { $io } = useNuxtApp(); - $io.on(`addChannel-${this.server.id}`, (ev) => { + (await $io).on(`addChannel-${this.server.id}`, (ev) => { const newChannel = ev as IChannel; useServerStore().addChannel(this.server.id, newChannel); }); diff --git a/server/middleware/socket.ts b/server/middleware/socket.ts index 23fb917..9198d93 100755 --- a/server/middleware/socket.ts +++ b/server/middleware/socket.ts @@ -12,8 +12,6 @@ export default defineEventHandler(({ node }) => { global.io.on('connection', async (socket: Socket) => { const token = socket.handshake.auth.token; - console.log(token); - if (!token) { socket.disconnect(); return;