feat(realtime): implement SSE realtime notifications; publish events from resolvers; remove polling in chat/sidebar/supplies/warehouse and wire realtime refetch
This commit is contained in:
@ -46,6 +46,7 @@ import {
|
||||
} from '@/graphql/queries'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useSidebar } from '@/hooks/useSidebar'
|
||||
import { useRealtime } from '@/hooks/useRealtime'
|
||||
|
||||
import { WbReturnClaims } from './wb-return-claims'
|
||||
|
||||
@ -238,7 +239,26 @@ export function FulfillmentWarehouseDashboard() {
|
||||
refetch: refetchWarehouseStats,
|
||||
} = useQuery(GET_FULFILLMENT_WAREHOUSE_STATS, {
|
||||
fetchPolicy: 'no-cache', // Принудительно обходим кеш
|
||||
pollInterval: 60000, // Обновляем каждую минуту
|
||||
})
|
||||
|
||||
// Real-time: обновляем ключевые блоки при событиях поставок/склада
|
||||
useRealtime({
|
||||
onEvent: (evt) => {
|
||||
switch (evt.type) {
|
||||
case 'supply-order:new':
|
||||
case 'supply-order:updated':
|
||||
refetchOrders()
|
||||
refetchWarehouseStats()
|
||||
refetchProducts()
|
||||
refetchSellerSupplies()
|
||||
refetchFulfillmentSupplies()
|
||||
break
|
||||
case 'warehouse:changed':
|
||||
refetchWarehouseStats()
|
||||
refetchFulfillmentSupplies()
|
||||
break
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// Логируем статистику склада для отладки
|
||||
|
Reference in New Issue
Block a user