aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-12 17:49:58 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-12 17:49:58 -0700
commit229fa227311adb2e4bfdfcd509669264ad793e9c (patch)
treefc3cd9e003b32e58f3e4fb84afaa4662667c9503 /modern
parentf7f327864fe85da3e14e07ea139f758870b9cb1b (diff)
downloadtrackermap-web-229fa227311adb2e4bfdfcd509669264ad793e9c.tar.gz
trackermap-web-229fa227311adb2e4bfdfcd509669264ad793e9c.tar.bz2
trackermap-web-229fa227311adb2e4bfdfcd509669264ad793e9c.zip
Refresh device list time
Diffstat (limited to 'modern')
-rw-r--r--modern/src/main/DevicesList.js11
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) {