aboutsummaryrefslogtreecommitdiff
path: root/modern/src/SocketController.js
diff options
context:
space:
mode:
authorLucas Leite <lbl.lucasleite@gmail.com>2022-02-13 10:00:09 -0300
committerLucas Leite <lbl.lucasleite@gmail.com>2022-02-13 10:00:09 -0300
commit51a5b5119688333a478c185e20668529d10aa022 (patch)
treefc9c45e5ed5da594ed1f4655d11bd7e80c061b33 /modern/src/SocketController.js
parent52a40cb71f11f04765bab8864146a3eadf81a26a (diff)
downloadtrackermap-web-51a5b5119688333a478c185e20668529d10aa022.tar.gz
trackermap-web-51a5b5119688333a478c185e20668529d10aa022.tar.bz2
trackermap-web-51a5b5119688333a478c185e20668529d10aa022.zip
Changed notification approach
Diffstat (limited to 'modern/src/SocketController.js')
-rw-r--r--modern/src/SocketController.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js
index 4b1f5733..69932fce 100644
--- a/modern/src/SocketController.js
+++ b/modern/src/SocketController.js
@@ -75,13 +75,13 @@ const SocketController = () => {
}, [authenticated]);
useEffect(() => {
- setNotifications(events.map((event) => {
- event.message = `${devices[event.deviceId]?.name}: ${t(prefixString('event', event.type))}`;
- event.show = true;
- setTimeout(() => event.show = false, 5000);
- return event;
- }));
- }, [events]);
+ setNotifications(events.map((event) => ({
+ id: event.id,
+ message: `${devices[event.deviceId]?.name}: ${t(prefixString('event', event.type))}`,
+ show: true,
+ close: () => setEvents(events.filter((e) => e.id !== event.id)),
+ })));
+ }, [events, devices]);
return (
<>
@@ -94,6 +94,8 @@ const SocketController = () => {
}}
open={notification.show}
message={notification.message}
+ autoHideDuration={5000}
+ onClose={notification.close}
/>
))}
</>