msToMinAndSec

master
Tudor Stanciu 2021-04-21 22:52:06 +03:00
parent 9780b42cd1
commit 8c6c76b329
2 changed files with 14 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import { PowerSettingsNew } from "@material-ui/icons";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useToast } from "../../../hooks"; import { useToast } from "../../../hooks";
import * as api from "../api"; import * as api from "../api";
import { msToMinAndSec } from "../../../utils/time";
const initialState = { on: false }; const initialState = { on: false };
const defaultPingInterval = 1200000; //20 minutes const defaultPingInterval = 1200000; //20 minutes
@ -43,7 +44,11 @@ const WakeComponent = ({ machine, addLog }) => {
success(result.status); success(result.status);
//retrigger //retrigger
log(`Periodic ping will be re-triggered in ${startingTime} ms.`); log(
`Periodic ping will be re-triggered in ${startingTime} ms [${msToMinAndSec(
startingTime
)}]`
);
setTimeout(() => { setTimeout(() => {
setTrigger(prev => !prev); setTrigger(prev => !prev);
}, startingTime); }, startingTime);

8
src/utils/time.js Normal file
View File

@ -0,0 +1,8 @@
function msToMinAndSec(ms) {
const minutes = Math.floor(ms / 60000);
const seconds = ((ms % 60000) / 1000).toFixed(0);
return `${minutes}m ${seconds}s`;
}
export { msToMinAndSec };