Refactor useWebSocket hook to use ReturnType for timeout and interval references; add TicketNotification types for handling ticket notifications.

This commit is contained in:
PEDZEO
2026-01-19 00:08:38 +03:00
parent 1960b0da2a
commit 6da090d79f
2 changed files with 21 additions and 2 deletions

View File

@@ -19,8 +19,8 @@ interface UseWebSocketOptions {
export function useWebSocket(options: UseWebSocketOptions = {}) { export function useWebSocket(options: UseWebSocketOptions = {}) {
const { accessToken, isAuthenticated } = useAuthStore() const { accessToken, isAuthenticated } = useAuthStore()
const wsRef = useRef<WebSocket | null>(null) const wsRef = useRef<WebSocket | null>(null)
const reconnectTimeoutRef = useRef<NodeJS.Timeout | null>(null) const reconnectTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
const pingIntervalRef = useRef<NodeJS.Timeout | null>(null) const pingIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null)
const [isConnected, setIsConnected] = useState(false) const [isConnected, setIsConnected] = useState(false)
const reconnectAttemptsRef = useRef(0) const reconnectAttemptsRef = useRef(0)
const maxReconnectAttempts = 5 const maxReconnectAttempts = 5

View File

@@ -516,3 +516,22 @@ export interface ManualCheckResponse {
old_status: string | null old_status: string | null
new_status: string | null new_status: string | null
} }
// Ticket notification types
export interface TicketNotification {
id: number
ticket_id: number
notification_type: string
message: string
is_read: boolean
created_at: string
}
export interface TicketNotificationList {
items: TicketNotification[]
total: number
}
export interface UnreadCountResponse {
unread_count: number
}