mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
fix(client): five loads that catch their own error recover from a deploy too
The PDF export on desktop and phone, the language switch, the holiday regions and the PDF's map image load a chunk on demand and catch the failure themselves. After a deploy the old page asks for chunk names the new build no longer has, so they showed their own error on every retry (or, for the language, silently stayed in the old one) instead of reloading onto the new build the way an uncaught chunk error does. importChunk reloads once for a missing chunk and still hands the caller its error.
This commit is contained in:
@@ -2,6 +2,7 @@ import { buildRouteOverlay, wrapSvg } from './tripMapSvg'
|
||||
import { hasWebGL } from '../../utils/webgl'
|
||||
import { normalizeStyleForProvider } from '../Map/glProviders'
|
||||
import type { TripOverviewDay } from '../Map/tripRouteGeometry'
|
||||
import { importChunk } from '../../utils/chunkReload'
|
||||
|
||||
/**
|
||||
* The trip's route over a real basemap, for the PDF (#1736).
|
||||
@@ -46,7 +47,7 @@ export async function renderTripMapImage(
|
||||
let container: HTMLDivElement | null = null
|
||||
let map: { remove: () => void } | null = null
|
||||
try {
|
||||
const gl = (await import('../Map/engines/maplibre')).default
|
||||
const gl = (await importChunk(() => import('../Map/engines/maplibre'))).default
|
||||
|
||||
container = document.createElement('div')
|
||||
// Off-screen rather than hidden: MapLibre needs a laid-out box with real
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useSettingsStore } from '../../store/settingsStore'
|
||||
import { useRoadtripSettings } from '../../hooks/useRoadtripSettings'
|
||||
import { useAuthStore } from '../../store/authStore'
|
||||
import { hasPersonalPlan } from '../PDF/pdfScope'
|
||||
import { importChunk } from '../../utils/chunkReload'
|
||||
|
||||
/**
|
||||
* What a GPX download can carry. Worded by what someone wants on their device
|
||||
@@ -98,7 +99,7 @@ export function TripExportModal({
|
||||
// sidebar, so every trip used to pay for it whether or not anyone
|
||||
// exported. A missing chunk lands in the catch and shows the same error
|
||||
// the export already had.
|
||||
const { downloadTripPDF } = await import('../PDF/TripPDF')
|
||||
const { downloadTripPDF } = await importChunk(() => import('../PDF/TripPDF'))
|
||||
await downloadTripPDF({ trip, days, places, assignments, categories, dayNotes: flatNotes, reservations, t, locale, timeFormat, distanceUnit, showServiceStops, onlyUserId: mine ? myId : undefined })
|
||||
onClose()
|
||||
} catch (e) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { schoolHolidayCatalogRepo } from '../../repo/schoolHolidayCatalogRepo'
|
||||
import apiClient from '../../api/client'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
import { SCHOOL_HOLIDAY_COUNTRY_CONFIG } from '../../vacay/schoolHolidayCountries'
|
||||
import { importChunk } from '../../utils/chunkReload'
|
||||
|
||||
// Loads the subdivision (state/region) options for a holiday-calendar country.
|
||||
//
|
||||
@@ -23,7 +24,7 @@ export async function fetchRegionOptions(country: string): Promise<{ value: stri
|
||||
// that get a region picker at all. Deliberately inside the try — if the chunk
|
||||
// fails, the result is the same empty array as a failed request, rather than an
|
||||
// unhandled rejection in the two callers that only do .then(setRegions).
|
||||
const iso31662 = (await import('iso-3166-2')).default
|
||||
const iso31662 = (await importChunk(() => import('iso-3166-2'))).default
|
||||
|
||||
const opts = new Map<string, string>() // ISO code -> display name
|
||||
const sub = iso31662.country(country)?.sub || {}
|
||||
|
||||
Reference in New Issue
Block a user