1
0
forked from noxious/client

#244: Allow nickname changes, fixed listening for notifications

This commit is contained in:
2025-02-19 11:46:05 +01:00
parent ffc7efb17c
commit 51e885cfdf
2 changed files with 9 additions and 6 deletions

View File

@ -14,7 +14,7 @@ import { SocketEvent } from '@/application/enums'
import Modal from '@/components/utilities/Modal.vue'
import { socketManager } from '@/managers/SocketManager'
import { useGameStore } from '@/stores/gameStore'
import { onBeforeMount, onBeforeUnmount, onMounted, onUnmounted, watch } from 'vue'
import { onMounted, onUnmounted, watch } from 'vue'
const gameStore = useGameStore()
@ -37,13 +37,13 @@ function setupNotificationListener(connection: any) {
}
onMounted(() => {
const connection = gameStore.connection
const connection = socketManager.connection
if (connection) {
setupNotificationListener(connection)
} else {
// Watch for changes in the socket connection
watch(
() => gameStore.connection,
() => socketManager.connection,
(newConnection) => {
if (newConnection) setupNotificationListener(newConnection)
}
@ -52,7 +52,7 @@ onMounted(() => {
})
onUnmounted(() => {
const connection = gameStore.connection
const connection = socketManager.connection
if (connection) {
connection.off(SocketEvent.NOTIFICATION)
}