mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +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 = () => {
|
const handleEndCall = () => {
|
||||||
setModal(false)
|
setModal(false);
|
||||||
Nui.send('phone:endCall', {
|
Nui.send('phone:endCall', {
|
||||||
transmitterNumber: call.transmitter,
|
transmitterNumber: call.transmitter,
|
||||||
});
|
});
|
||||||
@@ -41,9 +41,8 @@ export const CallModal = () => {
|
|||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppContent>
|
<AppContent>
|
||||||
|
|
||||||
<h1 style={{ textAlign: 'center' }}>{call.receiver}</h1>
|
<h1 style={{ textAlign: 'center' }}>{call.receiver}</h1>
|
||||||
<CallTimer isAccepted={call.accepted}/>
|
<CallTimer isAccepted={call.accepted} />
|
||||||
<div className={classes.actions}>
|
<div className={classes.actions}>
|
||||||
<Fab
|
<Fab
|
||||||
onClick={handleEndCall}
|
onClick={handleEndCall}
|
||||||
@@ -62,7 +61,7 @@ export const CallModal = () => {
|
|||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<h1 style={{ textAlign: 'center' }}>{call.transmitter}</h1>
|
<h1 style={{ textAlign: 'center' }}>{call.transmitter}</h1>
|
||||||
<CallTimer isAccepted={call.accepted}/>
|
<CallTimer isAccepted={call.accepted} />
|
||||||
<div className={classes.actions}>
|
<div className={classes.actions}>
|
||||||
{!call.accepted ? (
|
{!call.accepted ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,49 +1,54 @@
|
|||||||
import React, { useState, useCallback, useEffect } from 'react'
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
function CallTimer({ isAccepted }) {
|
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(() => {
|
useEffect(() => {
|
||||||
let timer = null
|
let timer = null;
|
||||||
if (isAccepted) {
|
if (isAccepted) {
|
||||||
run()
|
run();
|
||||||
timer = setInterval(run, 10)
|
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 = () => {
|
const run = () => {
|
||||||
if (updatedM === 60) {
|
if (updatedM === 60) {
|
||||||
updatedH++;
|
updatedH++;
|
||||||
updatedM = 0;
|
updatedM = 0;
|
||||||
}
|
}
|
||||||
if (updatedS === 60) {
|
if (updatedS === 60) {
|
||||||
updatedM++;
|
updatedM++;
|
||||||
updatedS = 0;
|
updatedS = 0;
|
||||||
}
|
}
|
||||||
if (updatedMs === 100) {
|
if (updatedMs === 100) {
|
||||||
updatedS++;
|
updatedS++;
|
||||||
updatedMs = 0
|
updatedMs = 0;
|
||||||
}
|
}
|
||||||
updatedMs++;
|
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;
|
if (!isAccepted) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div
|
||||||
textAlign: 'center',
|
style={{
|
||||||
marginTop: '2em',
|
textAlign: 'center',
|
||||||
fontSize: 30
|
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>
|
<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>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CallTimer
|
export default CallTimer;
|
||||||
Reference in new issue
Block a user