Skip to content

Commit

Permalink
CoverTheme: Store palette cache
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ckoates committed Aug 26, 2024
1 parent 8ffd294 commit 476fb6e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/CoverTheme/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import "./vibrant.native";
import { Tracer } from "@inrixia/lib/trace";
import { settings } from "./Settings";
export { Settings } from "./Settings";
import { storage } from "@plugin";

const trace = Tracer("[CoverTheme]");
let prevSong: string | undefined;
let prevCover: string | undefined;
let vars = new Set<string>();

export type Palette = { [key: string]: string };
const paletteCache = new Map<string, Palette>();
async function getPalette(coverId: string) {
if (paletteCache.has(coverId)) return paletteCache.get(coverId)!;
if (typeof storage.paletteCache !== "object") storage.paletteCache = {};
const cache = storage.paletteCache as { [key: string]: Palette };
if (cache[coverId]) return cache[coverId];
const palette = await makePalette(coverId);
paletteCache.set(coverId, palette);
return palette;
}

Expand Down

0 comments on commit 476fb6e

Please sign in to comment.