From 73fa8989a5909b5078d299dcf37f5484a2a5b313 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Mon, 11 Mar 2024 14:59:00 +0100 Subject: [PATCH] Automatically clear notification when connection is restored --- src/manager.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/manager.tsx b/src/manager.tsx index 4a330653..d4e34909 100644 --- a/src/manager.tsx +++ b/src/manager.tsx @@ -34,9 +34,15 @@ addons.register(ADDON_ID, (api) => { const channel = api.getChannel(); if (!channel) return; + let notificationShown = false; channel.on(`${ADDON_ID}/heartbeat`, () => { clearTimeout(heartbeatTimeout); + if (notificationShown) { + notificationShown = false; + api.clearNotification(`${ADDON_ID}/connection-lost`); + } heartbeatTimeout = setTimeout(() => { + notificationShown = true; api.addNotification({ id: `${ADDON_ID}/connection-lost`, content: {