Worked on zone manager

This commit is contained in:
2024-06-11 01:10:22 +02:00
parent 399e994bbe
commit 8e174a063a
29 changed files with 658 additions and 379 deletions

View File

@ -15,7 +15,7 @@
import { useNotificationStore } from '@/stores/notifications'
import { useSocketStore } from '@/stores/socket'
import Modal from '@/components/utilities/Modal.vue'
import { onMounted, onUnmounted, ref, watch } from 'vue'
import { onBeforeMount, onBeforeUnmount, watch } from 'vue'
const notifications = useNotificationStore()
const socket = useSocketStore()
@ -32,14 +32,14 @@ function setupNotificationListener(connection: any) {
})
}
onMounted(() => {
const connection = socket.getConnection
onBeforeMount(() => {
const connection = socket.connection
if (connection) {
setupNotificationListener(connection)
} else {
// Watch for changes in the socket connection
watch(
() => socket.getConnection,
() => socket.connection,
(newConnection) => {
if (newConnection) setupNotificationListener(newConnection)
}
@ -47,8 +47,8 @@ onMounted(() => {
}
})
onUnmounted(() => {
const connection = socket.getConnection
onBeforeUnmount(() => {
const connection = socket.connection
if (connection) {
connection.off('notification')
}