diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-12 17:49:58 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-12 17:49:58 -0700 |
commit | 229fa227311adb2e4bfdfcd509669264ad793e9c (patch) | |
tree | fc3cd9e003b32e58f3e4fb84afaa4662667c9503 /modern/src/main/DevicesList.js | |
parent | f7f327864fe85da3e14e07ea139f758870b9cb1b (diff) | |
download | trackermap-web-229fa227311adb2e4bfdfcd509669264ad793e9c.tar.gz trackermap-web-229fa227311adb2e4bfdfcd509669264ad793e9c.tar.bz2 trackermap-web-229fa227311adb2e4bfdfcd509669264ad793e9c.zip |
Refresh device list time
Diffstat (limited to 'modern/src/main/DevicesList.js')
-rw-r--r-- | modern/src/main/DevicesList.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modern/src/main/DevicesList.js b/modern/src/main/DevicesList.js index e1db7853..a91b81e2 100644 --- a/modern/src/main/DevicesList.js +++ b/modern/src/main/DevicesList.js @@ -1,4 +1,4 @@ -import React, { useRef } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import makeStyles from '@mui/styles/makeStyles'; import { @@ -156,6 +156,15 @@ const DevicesList = ({ devices }) => { listInnerEl.current.className = classes.listInner; } + const [, setTime] = useState(Date.now()); + + useEffect(() => { + const interval = setInterval(() => setTime(Date.now()), 60000); + return () => { + clearInterval(interval); + }; + }, []); + useEffectAsync(async () => { const response = await fetch('/api/devices'); if (response.ok) { |