mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
Prettified Code!
This commit is contained in:
1 parent
dd008775f9
commit
8621cab587
2 files changed
+31
-27
No files matched your search
@@ -31,7 +31,7 @@ export const CallModal = () => {
|
||||
};
|
||||
|
||||
const handleEndCall = () => {
|
||||
setModal(false)
|
||||
setModal(false);
|
||||
Nui.send('phone:endCall', {
|
||||
transmitterNumber: call.transmitter,
|
||||
});
|
||||
@@ -41,9 +41,8 @@ export const CallModal = () => {
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppContent>
|
||||
|
||||
<h1 style={{ textAlign: 'center' }}>{call.receiver}</h1>
|
||||
<CallTimer isAccepted={call.accepted}/>
|
||||
<CallTimer isAccepted={call.accepted} />
|
||||
<div className={classes.actions}>
|
||||
<Fab
|
||||
onClick={handleEndCall}
|
||||
@@ -62,7 +61,7 @@ export const CallModal = () => {
|
||||
<AppWrapper>
|
||||
<AppContent>
|
||||
<h1 style={{ textAlign: 'center' }}>{call.transmitter}</h1>
|
||||
<CallTimer isAccepted={call.accepted}/>
|
||||
<CallTimer isAccepted={call.accepted} />
|
||||
<div className={classes.actions}>
|
||||
{!call.accepted ? (
|
||||
<>
|
||||
|
||||
@@ -1,49 +1,54 @@
|
||||
import React, { useState, useCallback, useEffect } from 'react'
|
||||
import React, { useState, useCallback, useEffect } from 'react';
|
||||
|
||||
function CallTimer({ isAccepted }) {
|
||||
const [time, setTime] = useState({ ms: 0, s: 0, m: 0, h: 0 })
|
||||
const [time, setTime] = useState({ ms: 0, s: 0, m: 0, h: 0 });
|
||||
|
||||
useEffect(() => {
|
||||
let timer = null
|
||||
let timer = null;
|
||||
if (isAccepted) {
|
||||
run()
|
||||
timer = setInterval(run, 10)
|
||||
run();
|
||||
timer = setInterval(run, 10);
|
||||
}
|
||||
return () => clearInterval(timer)
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
let updatedMs = time.ms, updatedS = time.s, updatedM = time.m, updatedH = time.h;
|
||||
|
||||
let updatedMs = time.ms,
|
||||
updatedS = time.s,
|
||||
updatedM = time.m,
|
||||
updatedH = time.h;
|
||||
|
||||
const run = () => {
|
||||
if (updatedM === 60) {
|
||||
updatedH++;
|
||||
updatedM = 0;
|
||||
}
|
||||
}
|
||||
if (updatedS === 60) {
|
||||
updatedM++;
|
||||
updatedS = 0;
|
||||
}
|
||||
}
|
||||
if (updatedMs === 100) {
|
||||
updatedS++;
|
||||
updatedMs = 0
|
||||
updatedMs = 0;
|
||||
}
|
||||
updatedMs++;
|
||||
return setTime({ ms: updatedMs, s: updatedS, m: updatedM, h: updatedH })
|
||||
}
|
||||
return setTime({ ms: updatedMs, s: updatedS, m: updatedM, h: updatedH });
|
||||
};
|
||||
|
||||
if (!isAccepted) return null;
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
textAlign: 'center',
|
||||
marginTop: '2em',
|
||||
fontSize: 30
|
||||
}}>
|
||||
<span>{(time.h >= 10) ? time.h : '0'+time.h}</span> :
|
||||
<span>{(time.m >= 10) ? time.m : '0'+time.m}</span> :
|
||||
<span>{(time.s >= 10) ? time.s : '0'+time.s}</span>
|
||||
<div
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
marginTop: '2em',
|
||||
fontSize: 30,
|
||||
}}
|
||||
>
|
||||
<span>{time.h >= 10 ? time.h : '0' + time.h}</span> :
|
||||
<span>{time.m >= 10 ? time.m : '0' + time.m}</span> :
|
||||
<span>{time.s >= 10 ? time.s : '0' + time.s}</span>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export default CallTimer
|
||||
export default CallTimer;
|
||||
Reference in new issue
Block a user