aboutsummaryrefslogtreecommitdiff
path: root/modern/src/DeviceList.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-20 23:03:05 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-20 23:03:05 -0700
commit9238895c99c30c442ce8dae41b61f898a79dd89b (patch)
tree9488fa21fbcf6a78eefcf015ed73cd44e7415b97 /modern/src/DeviceList.js
parent37dd8129f8e07d00eb93262210bf1ecd4ce95532 (diff)
downloadtrackermap-web-9238895c99c30c442ce8dae41b61f898a79dd89b.tar.gz
trackermap-web-9238895c99c30c442ce8dae41b61f898a79dd89b.tar.bz2
trackermap-web-9238895c99c30c442ce8dae41b61f898a79dd89b.zip
Handle list refresh
Diffstat (limited to 'modern/src/DeviceList.js')
-rw-r--r--modern/src/DeviceList.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/modern/src/DeviceList.js b/modern/src/DeviceList.js
index b7c15dc4..c9abce3c 100644
--- a/modern/src/DeviceList.js
+++ b/modern/src/DeviceList.js
@@ -14,6 +14,7 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';
import { devicesActions } from './store';
import EditCollectionView from './EditCollectionView';
+import { useEffectAsync } from './reactHelper';
const useStyles = makeStyles(() => ({
list: {
@@ -22,12 +23,19 @@ const useStyles = makeStyles(() => ({
},
}));
-const DeviceView = ({ onMenuClick }) => {
+const DeviceView = ({ updateTimestamp, onMenuClick }) => {
const classes = useStyles();
const dispatch = useDispatch();
const items = useSelector(state => Object.values(state.devices.items));
+ useEffectAsync(async () => {
+ const response = await fetch('/api/devices');
+ if (response.ok) {
+ dispatch(devicesActions.refresh(await response.json()));
+ }
+ }, [updateTimestamp]);
+
return (
<List className={classes.list}>
{items.map((item, index, list) => (