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