mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
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:
1 parent
d90ac998aa
commit
019737286f
2 files changed
+18
No files matched your search
@@ -13,6 +13,14 @@ class ExportLocaleStore {
|
|||||||
_emptyMap = new Map();
|
_emptyMap = new Map();
|
||||||
|
|
||||||
async loadLocale(modPackId: number, cacheEntry: ExportLocaleCacheEntry) {
|
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}`);
|
let response = await fetch(`${staticRoot}static/${cacheEntry.localePath}`);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
cacheEntry.data = new Map(await response.json() as ExportLocale);
|
cacheEntry.data = new Map(await response.json() as ExportLocale);
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ interface MetadataCacheEntry {
|
|||||||
class ExportPrototypeMetadataStore {
|
class ExportPrototypeMetadataStore {
|
||||||
cache = new Map<number, MetadataCacheEntry>();
|
cache = new Map<number, MetadataCacheEntry>();
|
||||||
async loadMetadata(modPackId: number, cacheEntry: 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}`);
|
const response = await fetch(`${staticRoot}static/${cacheEntry.metadataPath}`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
notify(
|
notify(
|
||||||
|
|||||||
Reference in new issue
Block a user