261102_07_FIX: 통화 중 새로고침 시 컨택 페이지 이탈 방지 및 CTI 송수신 로그 추가
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { Suspense, useEffect, useMemo, useState } from "react";
|
||||
import { Suspense, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { ArrowLeft, RefreshCw } from "lucide-react";
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
@@ -37,6 +37,7 @@ const ListContactPageContent = () => {
|
||||
const userRole = auth?.user?.userRole ?? 0;
|
||||
const ctiCallPhase = useCtiCallPhase();
|
||||
const shouldBlockNavigation = CTI_CALL_PHASE.includes(ctiCallPhase);
|
||||
const hasObservedCall = useRef(false);
|
||||
|
||||
const queriesEnabled = mounted && prjctIdx > 0;
|
||||
const enabled = queriesEnabled && !!sid;
|
||||
@@ -74,10 +75,12 @@ const ListContactPageContent = () => {
|
||||
const hasGuardEntry = window.history.state?.[CALL_NAVIGATION_GUARD_KEY] === true;
|
||||
|
||||
if (!shouldBlockNavigation) {
|
||||
if (hasGuardEntry) window.history.back();
|
||||
if (hasGuardEntry && hasObservedCall.current) window.history.back();
|
||||
hasObservedCall.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
hasObservedCall.current = true;
|
||||
let isRestoringHistory = false;
|
||||
|
||||
if (!hasGuardEntry) {
|
||||
|
||||
@@ -756,6 +756,7 @@ const send = (command: Record<string, string>): boolean => {
|
||||
if (!socket || socket.readyState !== WebSocket.OPEN) return false;
|
||||
try {
|
||||
socket.send(JSON.stringify(command));
|
||||
console.log("[CTI][TEMP_LOG] send ->", command); // TEMP_CTI_LOG
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
@@ -817,7 +818,10 @@ const openSocketAndLogin = (params: CtiLoginParams) => {
|
||||
AgentGroup: CTI_AGENT_GROUP, ANINumber: params.aniNumber, AgentPhone: params.agentPhone });
|
||||
};
|
||||
ws.onmessage = (event) => {
|
||||
if (socket === ws) handleIncomingMessage(event.data);
|
||||
if (socket === ws) {
|
||||
console.log("[CTI][TEMP_LOG] message <-", event.data); // TEMP_CTI_LOG
|
||||
handleIncomingMessage(event.data);
|
||||
}
|
||||
};
|
||||
ws.onerror = () => console.warn("[CTI] WebSocket 연결 오류");
|
||||
ws.onclose = () => {
|
||||
|
||||
Reference in New Issue
Block a user