Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile fetching failure toast #1108

Merged
merged 6 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/routes/plans/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
externalResourceNames,
externalResources,
fetchingResources,
fetchingResourcesExternal,
resetSimulationStores,
resourceTypes,
resources,
Expand Down Expand Up @@ -336,6 +337,7 @@
} else {
simulationDataAbortController?.abort();
fetchingResources.set(false);
fetchingResourcesExternal.set(false);
$resources = [];
$spans = [];
}
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2873,6 +2873,7 @@ const effects = {
const error = e as Error;
if (error.name !== 'AbortError') {
catchError(error);
showFailureToast('Failed to fetch profiles');
fetchingResources.set(false);
}
return [];
Expand Down Expand Up @@ -2926,6 +2927,7 @@ const effects = {
const error = e as Error;
if (error.name !== 'AbortError') {
catchError(error);
showFailureToast('Failed to fetch external profiles');
fetchingResourcesExternal.set(false);
}
return [];
Expand Down
9 changes: 9 additions & 0 deletions src/utilities/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ function findToast(toastText: string, checkIsClosed: boolean = false) {
}

function hideToast(toast: Toast) {
// Only hide toast if in browser context
if (typeof document === 'undefined') {
duranb marked this conversation as resolved.
Show resolved Hide resolved
return;
}

toast.options.close = true;
toast.hideToast();
}
Expand All @@ -35,6 +40,10 @@ function toastCallback(this: Element) {
}

function showToast(toast: Toast) {
// Only show toast if in browser context
if (typeof document === 'undefined') {
return;
}
const toastText = toast.options.text;
const existingToastIndex = toastText !== undefined ? findToast(toastText, true) : -1;

Expand Down
Loading