fixed review comments

This commit is contained in:
Quan HL
2023-10-27 07:29:25 +07:00
parent fa23229d89
commit 86b48107f2
5 changed files with 30 additions and 5 deletions

2
package-lock.json generated
View File

@@ -19,7 +19,7 @@
"framer-motion": "^10.16.4",
"fuse.js": "^6.6.2",
"google-libphonenumber": "^3.2.33",
"jssip": "^3.2.17",
"jssip": "^3.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-feather": "^2.0.10",

View File

@@ -14,7 +14,7 @@
"framer-motion": "^10.16.4",
"fuse.js": "^6.6.2",
"google-libphonenumber": "^3.2.33",
"jssip": "^3.2.17",
"jssip": "^3.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-feather": "^2.0.10",

View File

@@ -73,5 +73,12 @@ export interface CallHistory {
isSaved?: boolean;
}
export type SipClientStatus = "online" | "offline";
export type SipClientStatus =
| "start"
| "stop"
| "connecting"
| "connected"
| "disconnected"
| "online"
| "offline";
export type SipCallDirection = "" | "outgoing" | "incoming";

View File

@@ -12,6 +12,7 @@ import {
Text,
Tooltip,
VStack,
useToast,
} from "@chakra-ui/react";
import { useEffect, useRef, useState } from "react";
import {
@@ -53,6 +54,7 @@ import { v4 as uuidv4 } from "uuid";
import IconButtonMenu, { IconButtonMenuItems } from "src/components/menu";
import { getApplications, getQueues, getRegisteredUser } from "src/api";
import JambonzSwitch from "src/components/switch";
import { DEFAULT_TOAST_DURATION } from "src/common/constants";
type PhoneProbs = {
sipDomain: string;
@@ -96,6 +98,8 @@ export const Phone = ({
const sipPasswordRef = useRef("");
const sipServerAddressRef = useRef("");
const sipDisplayNameRef = useRef("");
const [isForceChangeUaStatus, setIsForceChangeUaStatus] = useState(false);
const toast = useToast();
useEffect(() => {
sipDomainRef.current = sipDomain;
@@ -151,6 +155,10 @@ export const Phone = ({
}
}, [calledANumber]);
useEffect(() => {
setIsForceChangeUaStatus(false);
}, [status]);
// useEffect(() => {
// chrome.runtime.onMessage.addListener(function (request) {
// const msg = request as Message<any>;
@@ -218,6 +226,16 @@ export const Phone = ({
} else {
clientGoOffline();
}
toast({
title: `User is not registered${args.cause ? `, ${args.cause}` : ""}`,
status: "warning",
duration: DEFAULT_TOAST_DURATION,
isClosable: true,
});
});
sipClient.on(SipConstants.UA_DISCONNECTED, (args) => {
setStatus("disconnected");
});
// Call Status
sipClient.on(SipConstants.SESSION_RINGING, (args) => {
@@ -402,8 +420,9 @@ export const Phone = ({
<JambonzSwitch
onlabel="Online"
offLabel="Offline"
initialCheck={status === "online"}
initialCheck={isOnline() || isForceChangeUaStatus}
onChange={(v) => {
setIsForceChangeUaStatus(true);
handleGoOffline(v ? "online" : "offline");
}}
/>

View File

@@ -14,7 +14,6 @@ import {
import { useEffect, useState } from "react";
import PasswordInput from "src/components/password-input";
import { getSettings, saveSettings } from "src/storage";
import InfoIcon from "src/imgs/icons/Info.svg";
import ResetIcon from "src/imgs/icons/Reset.svg";
import { AppSettings } from "src/common/types";
import { DEFAULT_TOAST_DURATION } from "src/common/constants";