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 = "";
}
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