Skip to content
Merged
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
23 changes: 20 additions & 3 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@ import OAuthCallback from "./pages/OAuthCallback";
import JiraCallback from "./pages/JiraCallback";
import PrivacyPage from "./pages/PrivacyPage";

const DashboardPage = lazy(() => import("./components/dashboard/DashboardPage"));
const OnboardingWizard = lazy(() => import("./components/onboarding/OnboardingWizard"));
const SettingsPage = lazy(() => import("./components/settings/SettingsPage"));
const CHUNK_RELOAD_KEY = "github-tracker:chunk-reload";
const CHUNK_RELOAD_MAX_AGE = 10_000;

function lazyWithReload(loader: Parameters<typeof lazy>[0]) {
return lazy(() =>
loader().catch((err) => {
const last = sessionStorage.getItem(CHUNK_RELOAD_KEY);
if (!last || Date.now() - Number(last) > CHUNK_RELOAD_MAX_AGE) {
sessionStorage.setItem(CHUNK_RELOAD_KEY, String(Date.now()));
window.location.reload();
return new Promise<never>(() => {});
}
throw err;
}),
);
}

const DashboardPage = lazyWithReload(() => import("./components/dashboard/DashboardPage"));
const OnboardingWizard = lazyWithReload(() => import("./components/onboarding/OnboardingWizard"));
const SettingsPage = lazyWithReload(() => import("./components/settings/SettingsPage"));

const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary);

Expand Down