Skip to content

Commit

Permalink
Automatically clear notification when connection is restored
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Mar 11, 2024
1 parent 28a7cc1 commit 73fa898
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 73fa898

Please sign in to comment.