mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Add initial time fraction left on time progress
This commit is contained in:
parent
56f9c35b50
commit
cc87054246
@ -8,16 +8,21 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const LinearDeterminate = ({ expiresAt, totalSecsExp }: Props): JSX.Element => {
|
const LinearDeterminate = ({ expiresAt, totalSecsExp }: Props): JSX.Element => {
|
||||||
const [progress, setProgress] = useState<number>(100);
|
const timePercentLeft = function(){
|
||||||
|
if (expiresAt && totalSecsExp){
|
||||||
|
const lapseTime = calcTimeDelta(new Date(expiresAt)).total / 1000;
|
||||||
|
return (lapseTime / totalSecsExp) * 100;
|
||||||
|
} else {
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [progress, setProgress] = useState<number>(timePercentLeft);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
const left = calcTimeDelta(new Date(expiresAt)).total / 1000;
|
setProgress(timePercentLeft);
|
||||||
const newProgress = (left / totalSecsExp) * 100;
|
|
||||||
|
|
||||||
setProgress(newProgress);
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user