From 019737286f96034b9b33289327a1644ab2cc2e5b Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Tue, 17 Mar 2026 23:32:04 +0100 Subject: [PATCH] Handle missing export in locale and metadata store In the future, removing exports is likely going to be a feature. Handle the case where the export data is removed from a mod pack in the locale and prototype metadata stores. --- packages/web_ui/src/store/export_locale_stores.ts | 8 ++++++++ .../src/store/export_prototype_metadata_store.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/web_ui/src/store/export_locale_stores.ts b/packages/web_ui/src/store/export_locale_stores.ts index f0a10ada..8d3c6d17 100644 --- a/packages/web_ui/src/store/export_locale_stores.ts +++ b/packages/web_ui/src/store/export_locale_stores.ts @@ -13,6 +13,14 @@ class ExportLocaleStore { _emptyMap = new Map(); async loadLocale(modPackId: number, cacheEntry: ExportLocaleCacheEntry) { + if (!cacheEntry.localePath) { + cacheEntry.data = new Map(); + for (const callback of cacheEntry.callbacks) { + callback(); + } + return; + } + let response = await fetch(`${staticRoot}static/${cacheEntry.localePath}`); if (response.ok) { cacheEntry.data = new Map(await response.json() as ExportLocale); diff --git a/packages/web_ui/src/store/export_prototype_metadata_store.ts b/packages/web_ui/src/store/export_prototype_metadata_store.ts index c8222ac6..59169fd3 100644 --- a/packages/web_ui/src/store/export_prototype_metadata_store.ts +++ b/packages/web_ui/src/store/export_prototype_metadata_store.ts @@ -16,6 +16,16 @@ interface MetadataCacheEntry { class ExportPrototypeMetadataStore { cache = new Map(); async loadMetadata(modPackId: number, cacheEntry: MetadataCacheEntry) { + if (!cacheEntry.metadataPath) { + // eslint-disable-next-line node/no-sync + cacheEntry.styleSheet.replaceSync(""); + cacheEntry.metadata = new Map(); + for (const callback of cacheEntry.callbacks) { + callback(); + } + return; + } + const response = await fetch(`${staticRoot}static/${cacheEntry.metadataPath}`); if (!response.ok) { notify(