Add getMyProcesses

This commit is contained in:
Sosthene 2025-08-25 01:13:11 +02:00
parent 64775af683
commit 770eedf39d

View File

@ -662,7 +662,42 @@ export class Service {
throw new Error('Failed to update process');
}
} catch (error) {
throw new Error(`WASM error: ${error}`);
const errorMessage = error instanceof Error ? error.message : String(error || 'Unknown error');
throw new Error(errorMessage);
}
}
public async getMyProcesses(): Promise<string[] | null> {
// If we're not paired yet, just skip it
let pairingProcessId = null;
try {
pairingProcessId = this.getPairingProcessId();
} catch (e) {
return null;
}
if (!pairingProcessId) {
return null;
}
try {
const newMyProcesses = new Set<string>();
// MyProcesses automatically contains pairing process
newMyProcesses.add(pairingProcessId);
for (const [processId, process] of Object.entries(this.processes)) {
try {
const roles = this.getRoles(process);
if (roles && this.rolesContainsMember(roles, pairingProcessId)) {
newMyProcesses.add(processId);
}
} catch (e) {
console.error(e);
}
}
return Array.from(newMyProcesses);
} catch (e) {
console.error("Failed to get processes:", e);
return null;
}
}