fixed the phone online toggle button is not able to turn off when wss is disconnect

This commit is contained in:
Quan HL
2024-09-13 17:41:20 +07:00
parent 8cf21f5fbf
commit 4154383755

View File

@@ -309,18 +309,24 @@ export const Phone = ({
unregisteredReasonRef.current = ""; unregisteredReasonRef.current = "";
} }
setStatus("disconnected"); setStatus("disconnected");
if (isRestartRef.current) { setIsOnline(false);
createSipClient(); setIsSwitchingUserStatus(false);
isRestartRef.current = false; if (sipUA.current) {
sipUA.current.stop();
} }
if (args.error) { if (args.error) {
toast({ toast({
title: `Cannot connect to ${sipServerAddress}, ${args.reason}`, title: `Cannot connect to ${sipServerAddress}${
args.reason ? `, ${args.reason}` : ""
}`,
status: "warning", status: "warning",
duration: DEFAULT_TOAST_DURATION, duration: DEFAULT_TOAST_DURATION,
isClosable: true, isClosable: true,
}); });
} else if (isRestartRef.current) {
createSipClient();
isRestartRef.current = false;
} }
}); });
// Call Status // Call Status