ui: Reload device on change event.

Fixes #319.
This commit is contained in:
Orne Brocaar 2023-11-13 14:17:45 +00:00
parent 464937169b
commit f81b868a31
2 changed files with 12 additions and 1 deletions

View File

@ -77,6 +77,8 @@ class DeviceStore extends EventEmitter {
return;
}
this.emit("change");
notification.success({
message: "Device updated",
duration: 3,

View File

@ -46,6 +46,15 @@ function DeviceLayout(props: IProps) {
const [lastSeenAt, setLastSeenAt] = useState<Date | undefined>(undefined);
useEffect(() => {
DeviceStore.on("change", loadDevice);
loadDevice();
return () => {
DeviceStore.removeAllListeners("change");
};
}, [devEui]);
const loadDevice = () => {
let req = new GetDeviceRequest();
req.setDevEui(devEui!);
@ -62,7 +71,7 @@ function DeviceLayout(props: IProps) {
setDeviceProfile(resp.getDeviceProfile());
});
});
}, [devEui]);
}
const deleteDevice = () => {
let req = new DeleteDeviceRequest();