feat: start checks

This commit is contained in:
2025-03-16 17:55:38 +00:00
parent 08d6a2a2fe
commit 8d55e92fc9
26 changed files with 456 additions and 211 deletions

View File

@ -57,7 +57,8 @@ export const useGeneralStore = defineStore('general', () => {
export const usePkgStore = defineStore('pkg', {
state: (): {
pkg: { [key: string]: Package };
offline: boolean;
networkStatus: 'connecting' | 'offline' | 'online';
showInstalled: boolean;
showDeprecated: boolean;
showNSFW: boolean;
availableCategories: Set<string>;
@ -66,7 +67,8 @@ export const usePkgStore = defineStore('pkg', {
} => {
return {
pkg: {},
offline: false,
networkStatus: 'connecting',
showInstalled: false,
showDeprecated: false,
showNSFW: false,
availableCategories: new Set(),
@ -79,12 +81,14 @@ export const usePkgStore = defineStore('pkg', {
fromName: (state) => (namespace: string, name: string) =>
state.pkg[`${namespace}-${name}`] ?? null,
all: (state) => Object.values(state),
allLocal: (state) =>
Object.values(state.pkg).filter((p) => p.loc?.kind === 'Mod'),
allLocal: (state) => Object.values(state.pkg).filter((p) => p.loc),
hasLocal: (state) => (key: string) =>
key in state.pkg && state.pkg[key].loc,
allRemote: (state) =>
Object.values(state.pkg).filter(
(p) =>
p.rmt !== null &&
(state.showInstalled || !p.loc) &&
(state.showDeprecated || !p.rmt.deprecated) &&
(state.showNSFW || !p.rmt.nsfw) &&
(state.includeCategories.length === 0 ||
@ -154,15 +158,16 @@ export const usePkgStore = defineStore('pkg', {
},
async fetch(nopopup: boolean) {
this.networkStatus = 'connecting';
try {
if (nopopup) {
await invoke_nopopup('fetch_listings');
} else {
await invoke('fetch_listings');
}
this.offline = false;
this.networkStatus = 'online';
} catch (e) {
this.offline = true;
this.networkStatus = 'offline';
return;
}
await this.reloadAll();
@ -243,11 +248,17 @@ export const usePrfStore = defineStore('prf', () => {
list.value = (await invoke('list_profiles')) as ProfileMeta[];
};
const togglePkg = async (pkg: Package | undefined, enable: boolean) => {
const togglePkg = async (
pkg: Package | string | undefined,
enable: boolean
) => {
if (pkg === undefined) {
return;
}
await invoke('toggle_package', { key: pkgKey(pkg), enable });
await invoke('toggle_package', {
key: typeof pkg === 'string' ? pkg : pkgKey(pkg),
enable,
});
await reload();
};