Mounting,unmounting commands event listener

This commit is contained in:
bourquecharles
2021-05-26 17:58:08 -04:00
parent 828c4318d7
commit 5e4d9d144e

View File

@@ -95,10 +95,6 @@ const DeviceCommands = ({ selectedDeviceId }) => {
});
};
eventBus.on("actionCompleted", () =>
getCommands()
);
const deleteCommand = async () => {
if (uuidDelete === '') {
return false;
@@ -196,6 +192,16 @@ const DeviceCommands = ({ selectedDeviceId }) => {
}
}, [selectedDeviceId, start, end]);
useEffect(() => {
eventBus.on("actionCompleted", () =>
getCommands()
);
return () => {
eventBus.remove("actionCompleted");
}
}, []);
useEffect(() => {
if (selectedDeviceId) {
setStart(addDays(new Date(), -3).toString());