before liquid glass
This commit is contained in:
@@ -2,6 +2,7 @@ import { ref, computed } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { api } from 'boot/axios'
|
||||
import { useProjectsStore } from 'stores/projects'
|
||||
import { useAuthStore } from 'stores/auth'
|
||||
import { useChatsStore } from 'stores/chats'
|
||||
import { useUsersStore } from 'stores/users'
|
||||
|
||||
@@ -12,6 +13,7 @@ export const useSSEStore = defineStore('sse', () => {
|
||||
const maxReconnectAttempts = 5
|
||||
|
||||
const projectsStore = useProjectsStore()
|
||||
const authStore = useAuthStore()
|
||||
const chatsStore = useChatsStore()
|
||||
const usersStore = useUsersStore()
|
||||
|
||||
@@ -61,33 +63,30 @@ export const useSSEStore = defineStore('sse', () => {
|
||||
const setupEventListeners = () => {
|
||||
if (!eventSource.value) return
|
||||
|
||||
eventSource.value.addEventListener('chat-attach', (event) => {
|
||||
eventSource.value.addEventListener('chat-update', (event) => {
|
||||
const data = JSON.parse(event.data)
|
||||
projectsStore.init().catch(() => {}) // for update count of chats on projects page
|
||||
authStore.updateProfile().catch(() => {}) // for update count of active chats in subscribe
|
||||
if (data.project_id === currentProjectId.value) {
|
||||
chatsStore.init().catch(() => {})
|
||||
usersStore.init().catch(() => {}) // for update users from chats
|
||||
}
|
||||
})
|
||||
|
||||
eventSource.value.addEventListener('chat-delete', (event) => {
|
||||
const data = JSON.parse(event.data)
|
||||
projectsStore.init().catch(() => {}) // for update count of chats on projects page
|
||||
authStore.updateProfile().catch(() => {}) // for update count of active chats in subscribe
|
||||
if (data.project_id === currentProjectId.value) {
|
||||
chatsStore.init().catch(() => {})
|
||||
usersStore.init().catch(() => {})
|
||||
usersStore.init().catch(() => {}) // for update users from chats
|
||||
}
|
||||
})
|
||||
|
||||
eventSource.value.addEventListener('chat-detach', (event) => {
|
||||
eventSource.value.addEventListener('customer-update', (event) => {
|
||||
const data = JSON.parse(event.data)
|
||||
if (data.project_id === currentProjectId.value) {
|
||||
chatsStore.detach(data.id)
|
||||
usersStore.init().catch(() => {})
|
||||
}
|
||||
})
|
||||
|
||||
eventSource.value.addEventListener('chat-update', (event) => {
|
||||
const data = JSON.parse(event.data)
|
||||
if (data.project_id === currentProjectId.value) {
|
||||
chatsStore.init().catch(() => {})
|
||||
authStore.updateProfile().catch(() => {})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user