Skip to content

Commit

Permalink
Merge pull request #351 from chromaui/valentin/remove-connection-time…
Browse files Browse the repository at this point in the history
…out-notification

Remove the connection timeout notification
  • Loading branch information
valentinpalkovic authored Jan 17, 2025
2 parents a7a43da + 127a468 commit dcee165
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
31 changes: 0 additions & 31 deletions src/manager.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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,
Expand Down Expand Up @@ -54,28 +47,4 @@ addons.register(ADDON_ID, (api) => {
render: () => <SidebarBottom api={api} />,
});
}

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: <FailedIcon color={color.negative} />,
link: undefined,
});
}, 3000);
});
});
2 changes: 0 additions & 2 deletions src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit dcee165

Please sign in to comment.