feat: less bad installations

This commit is contained in:
2025-02-23 20:54:47 +01:00
parent caead1e70f
commit 6236b8ef96
13 changed files with 124 additions and 58 deletions

View File

@ -29,12 +29,18 @@ export const usePkgStore = defineStore('pkg', {
actions: {
setupListeners() {
listen<InstallStatus>('install-start', async (ev) => {
await this.reload(ev.payload.pkg);
const key = ev.payload.pkg;
await this.reload(key);
this.pkg[key].js.busy = true;
console.log('install-start' + key);
});
listen<InstallStatus>('install-end', async (ev) => {
await this.reload(ev.payload.pkg);
const key = ev.payload.pkg;
await this.reload(key);
await this.reloadProfile();
this.pkg[key].js.busy = false;
console.log('install-end' + key);
});
},
@ -44,37 +50,28 @@ export const usePkgStore = defineStore('pkg', {
[key: string]: Package;
};
for (const k of Object.keys(this)) {
delete this.pkg[k];
for (const [k, v] of Object.entries(data)) {
this.reloadWith(k, v);
}
Object.assign(this.pkg, data);
if (this.prf !== null)
for (const [k, v] of Object.entries(this)) {
if (this.prf.mods.includes(k)) {
if (v.loc) {
v.loc.enabled = true;
} else {
console.error(`${k} enabled but not present`);
}
}
}
},
async reload(pkgOrKey: string | Package) {
const key =
typeof pkgOrKey === 'string' ? pkgOrKey : pkgKey(pkgOrKey);
const rv: Package = await invoke('get_package', {
const pkg: Package = await invoke('get_package', {
key,
});
this.reloadWith(key, pkg);
},
async reloadWith(key: string, pkg: Package) {
if (this.pkg[key] === undefined) {
this.pkg[key] = {} as Package;
this.pkg[key] = { js: { busy: false } } as Package;
} else {
this.pkg[key].loc = null;
this.pkg[key].rmt = null;
}
Object.assign(this.pkg[key], rv);
Object.assign(this.pkg[key], pkg);
},
async initProfile(exePath: string) {