Skip to content

Commit

Permalink
Fixed api connector bgm cache not checking file name
Browse files Browse the repository at this point in the history
  • Loading branch information
squaresmile committed Aug 10, 2024
1 parent bb48ca0 commit 3bf6b4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/api-connector/src/ApiConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ApiConnector {
private cache = {
ai: new ResultCache<{ type: AiType; id: number }, AiCollection>(),
attributeAffinityMap: new ResultCache<null, AttributeAffinityMap>(),
bgm: new ResultCache<number, BgmEntity>(),
bgm: new ResultCache<string, BgmEntity>(),
bgmList: new ResultCache<null, BgmEntity[]>(),
buff: new ResultCache<number, Buff>(),
buffBasic: new ResultCache<number, BasicBuff>(),
Expand Down Expand Up @@ -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<BgmEntity[]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/Descriptor/BgmDescriptor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <BgmDescriptor {...props} />;
return <BgmDescriptor {...props} bgm={props.bgm} />;
} else {
return <BgmDescriptor {...props} bgm={bgmApi} />;
}
Expand Down

0 comments on commit 3bf6b4a

Please sign in to comment.