mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
mad formatting
This commit is contained in:
1 parent
6777498bcc
commit
046447b0fb
74 files changed
+329
-309
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { useDuration } from '../hooks/useDuration';
|
||||
|
||||
|
||||
const runTimer = (updatedTime, setDuration) => {
|
||||
let newTime = { ...updatedTime.current };
|
||||
if (newTime.m >= 60) {
|
||||
@@ -17,25 +16,24 @@ const runTimer = (updatedTime, setDuration) => {
|
||||
newTime = { ...newTime, ms: newTime.ms + 1 };
|
||||
updatedTime.current = newTime;
|
||||
setDuration(newTime);
|
||||
}
|
||||
};
|
||||
|
||||
function CallTimer({ isAccepted }) {
|
||||
const { duration, setDuration } = useDuration();
|
||||
const updatedTime = useRef({ ms: 0, s: 0, m: 0, h: 0 });
|
||||
const timer = useRef(null)
|
||||
|
||||
const timer = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAccepted) {
|
||||
runTimer(updatedTime, setDuration)
|
||||
runTimer(updatedTime, setDuration);
|
||||
timer.current = setInterval(() => {
|
||||
runTimer(updatedTime, setDuration)
|
||||
runTimer(updatedTime, setDuration);
|
||||
}, 10);
|
||||
} else {
|
||||
clearInterval(timer.current);
|
||||
timer.current = null;
|
||||
}
|
||||
return () => clearInterval(timer.current)
|
||||
return () => clearInterval(timer.current);
|
||||
}, [isAccepted, setDuration]);
|
||||
|
||||
if (!duration || !isAccepted) return null;
|
||||
|
||||
Reference in new issue
Block a user