updates: show updates for custom repos

This commit is contained in:
2 * r + 2 * t 2025-03-18 13:41:37 +11:00
parent 8f3b369e86
commit 18921c6847

View file

@ -92,6 +92,19 @@ export default class Updates extends GObject.Object {
); );
} }
getRepoIcon(repo: string) {
switch (repo) {
case "core":
return "hub";
case "extra":
return "add_circle";
case "multilib":
return "account_tree";
default:
return "deployed_code_update";
}
}
getUpdates() { getUpdates() {
// Return if already getting updates // Return if already getting updates
if (this.#loading) return; if (this.#loading) return;
@ -106,21 +119,14 @@ export default class Updates extends GObject.Object {
// Pacman updates (checkupdates) // Pacman updates (checkupdates)
if (pacman.status === "fulfilled") { if (pacman.status === "fulfilled") {
const repos: Repo[] = [ const repos: Repo[] = await Promise.all(
{ repo: await this.getRepo("core"), updates: [], icon: "hub", name: "Core repository" }, (await execAsync("pacman-conf -l")).split("\n").map(async r => ({
{ repo: await this.getRepo(r),
repo: await this.getRepo("extra"),
updates: [], updates: [],
icon: "add_circle", icon: this.getRepoIcon(r),
name: "Extra repository", name: r[0].toUpperCase() + r.slice(1) + " repository",
}, }))
{ );
repo: await this.getRepo("multilib"),
updates: [],
icon: "account_tree",
name: "Multilib repository",
},
];
for (const update of pacman.value.split("\n")) { for (const update of pacman.value.split("\n")) {
const pkg = update.split(" ")[0]; const pkg = update.split(" ")[0];