This is an experiment, whether this should live in the API or the
composable part I don't know, yet.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
return response.data;
}
+const cachedPackages = new Map<string, Package>();
+
// Fetch a package by its UUID
export async function fetchPackage(uuid: string): Promise<Package> {
+ let pkg = cachedPackages.get(uuid);
+ if (pkg)
+ return pkg;
+
+ // Fetch the package if not cached
const response = await api.get(`/v1/packages/${uuid}`);
- return response.data;
+ pkg = response.data as Package;
+
+ // Store this in the cache
+ cachedPackages.set(pkg.uuid, pkg);
+
+ return pkg;
}
// Fetch the package filelist