From 3bf6b4afe769022a396da39c6fb6af7b5a4eee79 Mon Sep 17 00:00:00 2001 From: squaresmile Date: Sat, 10 Aug 2024 07:14:03 -0400 Subject: [PATCH] Fixed api connector bgm cache not checking file name --- packages/api-connector/src/ApiConnector.ts | 6 ++++-- packages/db/src/Descriptor/BgmDescriptor.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/api-connector/src/ApiConnector.ts b/packages/api-connector/src/ApiConnector.ts index a322048d..87bd083c 100644 --- a/packages/api-connector/src/ApiConnector.ts +++ b/packages/api-connector/src/ApiConnector.ts @@ -135,7 +135,7 @@ class ApiConnector { private cache = { ai: new ResultCache<{ type: AiType; id: number }, AiCollection>(), attributeAffinityMap: new ResultCache(), - bgm: new ResultCache(), + bgm: new ResultCache(), bgmList: new ResultCache(), buff: new ResultCache(), buffBasic: new ResultCache(), @@ -315,7 +315,9 @@ class ApiConnector { if (cacheDuration === undefined) return fetch(); - return this.cache.bgm.get(id, fetch, cacheDuration <= 0 ? null : cacheDuration); + const cacheKey = `${id}${fileName || ""}`; + + return this.cache.bgm.get(cacheKey, fetch, cacheDuration <= 0 ? null : cacheDuration); } bgmList(cacheDuration?: number): Promise { diff --git a/packages/db/src/Descriptor/BgmDescriptor.tsx b/packages/db/src/Descriptor/BgmDescriptor.tsx index 6a364b0e..d132d588 100644 --- a/packages/db/src/Descriptor/BgmDescriptor.tsx +++ b/packages/db/src/Descriptor/BgmDescriptor.tsx @@ -37,7 +37,7 @@ export const BgmDescriptorFileName = (props: BgmProps & { bgm: Bgm.Bgm }) => { const { data: bgmApi } = useApi("bgm", -1, props.bgm.fileName); if (bgmApi === undefined) { - return ; + return ; } else { return ; }