diff options
author | Lucas Leite <lbl.lucasleite@gmail.com> | 2022-02-13 10:00:09 -0300 |
---|---|---|
committer | Lucas Leite <lbl.lucasleite@gmail.com> | 2022-02-13 10:00:09 -0300 |
commit | 51a5b5119688333a478c185e20668529d10aa022 (patch) | |
tree | fc9c45e5ed5da594ed1f4655d11bd7e80c061b33 | |
parent | 52a40cb71f11f04765bab8864146a3eadf81a26a (diff) | |
download | trackermap-web-51a5b5119688333a478c185e20668529d10aa022.tar.gz trackermap-web-51a5b5119688333a478c185e20668529d10aa022.tar.bz2 trackermap-web-51a5b5119688333a478c185e20668529d10aa022.zip |
Changed notification approach
-rw-r--r-- | modern/src/SocketController.js | 16 |
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} /> ))} </> |