Replace Date.getTime() with Date.now()
Change-Id: I7d458880d9f11346a2e2805d9f702f80d1cbf543
diff --git a/client/src/contexts/CallProvider.tsx b/client/src/contexts/CallProvider.tsx
index 000a91d..ce57691 100644
--- a/client/src/contexts/CallProvider.tsx
+++ b/client/src/contexts/CallProvider.tsx
@@ -51,7 +51,7 @@
setIsFullscreen: SetState<boolean>;
callRole: CallRole;
callStatus: CallStatus;
- callStartTime: Date | undefined;
+ callStartTime: number | undefined;
isAnswerButtonDisabled: boolean;
acceptCall: (withVideoOn: boolean) => void;
@@ -105,7 +105,7 @@
const [isFullscreen, setIsFullscreen] = useState(false);
const [callStatus, setCallStatus] = useState(routeState?.callStatus);
const [callRole] = useState(routeState?.role);
- const [callStartTime, setCallStartTime] = useState<Date | undefined>(undefined);
+ const [callStartTime, setCallStartTime] = useState<number | undefined>(undefined);
const [isAnswerButtonDisabled, setIsAnswerButtonDisabled] = useState(false);
// TODO: This logic will have to change to support multiple people in a call. Could we move this logic to the server?
@@ -248,7 +248,7 @@
) {
console.info('Changing call status to InCall');
setCallStatus(CallStatus.InCall);
- setCallStartTime(new Date());
+ setCallStartTime(Date.now());
}
}, [iceConnectionState, callStatus]);
diff --git a/client/src/pages/CallInterface.tsx b/client/src/pages/CallInterface.tsx
index beef803..3febdc0 100644
--- a/client/src/pages/CallInterface.tsx
+++ b/client/src/pages/CallInterface.tsx
@@ -167,13 +167,13 @@
const CallInterfaceInformation = () => {
const { callStartTime } = useContext(CallContext);
const { conversation } = useContext(ConversationContext);
- const [elapsedTime, setElapsedTime] = useState<number>(0);
+ const [elapsedTime, setElapsedTime] = useState(0);
const memberName = useMemo(() => conversation.getFirstMember().contact.getRegisteredName(), [conversation]);
useEffect(() => {
if (callStartTime) {
const interval = setInterval(() => {
- setElapsedTime((new Date().getTime() - callStartTime.getTime()) / 1000);
+ setElapsedTime((Date.now() - callStartTime) / 1000);
}, 1000);
return () => clearInterval(interval);
}