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.
This commit is contained in:
Hornwitser committed 2026-03-17 23:32:04 +01:00
1 parent d90ac998aa
commit 019737286f
2 files changed
+18

No files matched your search

@@ -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);
@@ -16,6 +16,16 @@ interface MetadataCacheEntry {
class ExportPrototypeMetadataStore {
cache = new Map<number, MetadataCacheEntry>();
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(