From 127a468c9e7a952857cc0028e7793b726c422fc3 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Fri, 17 Jan 2025 10:05:23 +0100 Subject: [PATCH] Remove the connection timeout notification --- src/manager.tsx | 31 ------------------------------- src/preset.ts | 2 -- 2 files changed, 33 deletions(-) diff --git a/src/manager.tsx b/src/manager.tsx index 6885c4cb..98937e4a 100644 --- a/src/manager.tsx +++ b/src/manager.tsx @@ -1,6 +1,4 @@ -import { FailedIcon } from "@storybook/icons"; import { addons, type API } from "@storybook/manager-api"; -import { color } from "@storybook/theming"; import { type Addon_TestProviderType, Addon_TypesEnum } from "@storybook/types"; import React from "react"; @@ -17,11 +15,6 @@ import { import { Panel } from "./Panel"; import { TestingModuleDescription } from "./TestingModuleDescription"; -let heartbeatTimeout: NodeJS.Timeout; -const expectHeartbeat = (api: API) => { - heartbeatTimeout = setTimeout(() => expectHeartbeat(api), 30000); -}; - addons.register(ADDON_ID, (api) => { addons.add(PANEL_ID, { type: Addon_TypesEnum.PANEL, @@ -54,28 +47,4 @@ addons.register(ADDON_ID, (api) => { render: () => , }); } - - const channel = api.getChannel(); - if (!channel) return; - - let notificationId: string | undefined; - channel.on(`${ADDON_ID}/heartbeat`, () => { - clearTimeout(heartbeatTimeout); - if (notificationId) { - api.clearNotification(notificationId); - notificationId = undefined; - } - heartbeatTimeout = setTimeout(() => { - notificationId = `${ADDON_ID}/connection-lost/${Date.now()}`; - api.addNotification({ - id: notificationId, - content: { - headline: "Connection lost", - subHeadline: "Lost connection to the Storybook server. Try refreshing the page.", - }, - icon: , - link: undefined, - }); - }, 3000); - }); }); diff --git a/src/preset.ts b/src/preset.ts index 4e8138a6..f33cae8b 100644 --- a/src/preset.ts +++ b/src/preset.ts @@ -294,8 +294,6 @@ async function serverChannel(channel: Channel, options: Options & { configFile?: configInfoState.value = await getConfigInfo(configuration, options); }); - setInterval(() => channel.emit(`${ADDON_ID}/heartbeat`), 1000); - channel.on(REMOVE_ADDON, () => { apiPromise.then((api) => api.removeAddon(PACKAGE_NAME)).catch((e) => console.error(e)); gitInfoObserver.cancel();