From 4154383755b4a12c327275d87d47d0e995d2cc9d Mon Sep 17 00:00:00 2001 From: Quan HL Date: Fri, 13 Sep 2024 17:41:20 +0700 Subject: [PATCH] fixed the phone online toggle button is not able to turn off when wss is disconnect --- src/window/phone/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/window/phone/index.tsx b/src/window/phone/index.tsx index 3db865e..dd3cd3a 100644 --- a/src/window/phone/index.tsx +++ b/src/window/phone/index.tsx @@ -309,18 +309,24 @@ export const Phone = ({ unregisteredReasonRef.current = ""; } setStatus("disconnected"); - if (isRestartRef.current) { - createSipClient(); - isRestartRef.current = false; + setIsOnline(false); + setIsSwitchingUserStatus(false); + if (sipUA.current) { + sipUA.current.stop(); } if (args.error) { toast({ - title: `Cannot connect to ${sipServerAddress}, ${args.reason}`, + title: `Cannot connect to ${sipServerAddress}${ + args.reason ? `, ${args.reason}` : "" + }`, status: "warning", duration: DEFAULT_TOAST_DURATION, isClosable: true, }); + } else if (isRestartRef.current) { + createSipClient(); + isRestartRef.current = false; } }); // Call Status