import Palette from "@/services/palette"; import Updates, { Repo as IRepo, Update as IUpdate } from "@/services/updates"; import { MenuItem } from "@/utils/widgets"; import PopdownWindow from "@/widgets/popdownwindow"; import { bind, execAsync, Variable } from "astal"; import { App, Astal, Gtk } from "astal/gtk3"; const constructItem = (label: string, exec: string, quiet = true) => new MenuItem({ label, onActivate() { App.get_window("updates")?.hide(); execAsync(exec).catch(e => !quiet && console.error(e)); }, }); const Update = (update: IUpdate) => { const menu = new Gtk.Menu(); menu.append(constructItem("Open info in browser", `xdg-open '${update.url}'`, false)); menu.append(constructItem("Open info in terminal", `uwsm app -- foot -H pacman -Qi ${update.name}`)); menu.append(new Gtk.SeparatorMenuItem({ visible: true })); menu.append(constructItem("Reinstall", `uwsm app -T -- yay -S ${update.name}`)); menu.append(constructItem("Remove with dependencies", `uwsm app -T -- yay -Rns ${update.name}`)); return ( ); }; const Repo = ({ repo, first }: { repo: IRepo; first?: boolean }) => { const expanded = Variable(first); return ( {repo.updates.map(Update)} ); }; const News = ({ news }: { news: string }) => { const expanded = Variable(true); return ( ); }; const List = () => ( {bind(Updates.get_default(), "updateData").as(d => d.news ? [, ...d.repos.map(r => )] : d.repos.map((r, i) => ) )} ); export default () => ( execAsync("uwsm app -T -- yay") .then(() => Updates.get_default().getUpdates()) // Ignore errors .catch(() => {}), }, { label: bind(Updates.get_default(), "loading").as(l => (l ? "Loading" : "Reload")), onClicked: () => Updates.get_default().getUpdates(), enabled: bind(Updates.get_default(), "loading"), }, ]} emptyIcon="deployed_code_history" emptyLabel="All packages up to date!" list={} /> );