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 all 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 @@ -85,6 +85,7 @@
externalResourceNames,
externalResources,
fetchingResources,
fetchingResourcesExternal,
resetSimulationStores,
resourceTypes,
resources,
Expand Down Expand Up @@ -341,6 +342,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 @@ -2882,6 +2882,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 @@ -2935,6 +2936,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