ui: fetch all Fedora releasevers (43+44), not just hardcoded 43
Some checks failed
deploy-ui / build-and-deploy (push) Has been cancelled

Fixes packages only showing one Fedora version (e.g. claude-desktop's
fc44 build was invisible). Generalises the hook to iterate RELEASEVERS.
This commit is contained in:
2026-07-02 07:51:48 +00:00
parent 6884a7992b
commit c341f7dd4d

View File

@@ -1,16 +1,41 @@
import { useEffect, useState } from "react";
import type { Channel, PackagesManifest, PackageVersion } from "../types/packages.ts";
const STABLE_URL = "/fedora/43/x86_64/packages.json";
const UNSTABLE_URL = "/fedora/43/x86_64/unstable/packages.json";
// Fedora releasevers served at rpm.lair.cafe. Add new versions here as trees
// come online; missing trees (e.g. a releasever with no unstable repo) 404 and
// are skipped gracefully.
const RELEASEVERS = ["43", "44"];
interface ManifestSource {
url: string;
channel: Channel;
releasever: string;
}
function manifestSources(): ManifestSource[] {
return RELEASEVERS.flatMap((releasever) => [
{
url: `/fedora/${releasever}/x86_64/packages.json`,
channel: "stable" as const,
releasever,
},
{
url: `/fedora/${releasever}/x86_64/unstable/packages.json`,
channel: "unstable" as const,
releasever,
},
]);
}
function tagPackages(
manifest: PackagesManifest,
channel: Channel,
releasever: string,
): PackageVersion[] {
return manifest.packages.map((p) => ({
...p,
channel,
releasever,
baseUrl: manifest.baseUrl,
}));
}
@@ -24,24 +49,20 @@ export function usePackages() {
let cancelled = false;
const fetchManifest = async (
url: string,
channel: Channel,
source: ManifestSource,
): Promise<PackageVersion[]> => {
const res = await fetch(url);
const res = await fetch(source.url);
if (!res.ok) {
if (res.status === 404) return [];
throw new Error(`HTTP ${res.status} fetching ${channel} manifest`);
throw new Error(`HTTP ${res.status} fetching ${source.url}`);
}
const data = (await res.json()) as PackagesManifest;
return tagPackages(data, channel);
return tagPackages(data, source.channel, source.releasever);
};
Promise.all([
fetchManifest(STABLE_URL, "stable"),
fetchManifest(UNSTABLE_URL, "unstable"),
])
.then(([stable, unstable]) => {
if (!cancelled) setPackages([...stable, ...unstable]);
Promise.all(manifestSources().map(fetchManifest))
.then((lists) => {
if (!cancelled) setPackages(lists.flat());
})
.catch((err: unknown) => {
if (!cancelled)