diff options
author | morpheus65535 <[email protected]> | 2021-11-02 22:16:40 -0400 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2021-11-02 22:16:40 -0400 |
commit | 9cf412fc695119a53a075d796e71117fe3fd6572 (patch) | |
tree | 746e711973b62f828edfd061bf560fa0ffda49a5 /frontend | |
parent | 876b33e27aeb2ac6da168741f7a2d7e85a5896ec (diff) | |
download | bazarr-9cf412fc695119a53a075d796e71117fe3fd6572.tar.gz bazarr-9cf412fc695119a53a075d796e71117fe3fd6572.zip |
no log: improvement to uptime interval
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/src/System/Status/index.tsx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/frontend/src/System/Status/index.tsx b/frontend/src/System/Status/index.tsx index c937995eb..1ac6507c3 100644 --- a/frontend/src/System/Status/index.tsx +++ b/frontend/src/System/Status/index.tsx @@ -7,9 +7,10 @@ import { import { faPaperPlane } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import moment from "moment"; -import React, { FunctionComponent, useEffect, useState } from "react"; +import React, { FunctionComponent, useState } from "react"; import { Col, Container, Row } from "react-bootstrap"; import { Helmet } from "react-helmet"; +import { useIntervalWhen } from "rooks"; import { useSystemHealth, useSystemStatus } from "../../@redux/hooks"; import { AsyncOverlay } from "../../components"; import { GithubRepoRoot } from "../../constants"; @@ -71,9 +72,10 @@ const SystemStatusView: FunctionComponent<Props> = () => { const status = useSystemStatus(); const [uptime, setState] = useState<string>(); + const [intervalWhenState] = useState(true); - useEffect(() => { - const interval = setInterval(() => { + useIntervalWhen( + () => { if (status) { let duration = moment.duration( moment().utc().unix() - status.start_time, @@ -85,9 +87,11 @@ const SystemStatusView: FunctionComponent<Props> = () => { seconds = duration.seconds().toString().padStart(2, "0"); setState(days + "d " + hours + ":" + minutes + ":" + seconds); } - }, 1000); - return () => clearInterval(interval); - }, [status]); + }, + 1000, + intervalWhenState, + true + ); return ( <Container className="p-5"> |