Skip to content

Commit

Permalink
fix: improves event stream error and only shows when closed
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Sep 27, 2023
1 parent a9afe7a commit 67dbbfc
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions assets/stores/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ export const useContainerStore = defineStore("container", () => {
ready.value = false;
es = new EventSource(`${config.base}/api/events/stream`);
es.addEventListener("error", (e) => {
showToast(
{
id: "events-stream",
message: t("error.events-stream.message"),
title: t("error.events-stream.title"),
type: "error",
},
{ once: true },
);
if (es?.readyState === EventSource.CLOSED) {
showToast(
{
id: "events-stream",
message: t("error.events-stream.message"),
title: t("error.events-stream.title"),
type: "error",
},
{ once: true },
);
}
});

es.addEventListener("containers-changed", (e: Event) =>
Expand Down

0 comments on commit 67dbbfc

Please sign in to comment.