forked from noxious/client
#244: Allow nickname changes, fixed listening for notifications
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user