getMyProcesses actually inspect all processes to find ours

This commit is contained in:
NicolasCantu 2025-02-11 23:29:39 +01:00
parent a380ee4f29
commit 239ddae893

View File

@ -1271,11 +1271,31 @@ export default class Services {
}
}
async getMyProcesses(): Promise<Set<>> {
return this.myProcesses;
}
async getMyProcesses(): Promise<Set<string>> {
try {
const processes = await this.getProcesses();
const userProcessSet = new Set<string>();
async getAllProcesses(): Promise<Set<>> {
return this.processes;
for (const [processId, process] of Object.entries(processes)) {
// We use myProcesses attribute to not reevaluate all processes everytime
if (this.myProcesses && this.myProcesses.has(processId)) {
userProcessSet.add(processId);
continue;
}
try {
const roles = await this.getRoles(process);
if (this.rolesContainsUs(roles)) {
this.myProcesses.add(processId);
userProcessSet.add(processId);
}
} catch (e) {
console.error(e);
}
}
return userProcessSet;
} catch (e) {
console.error("Failed to get processes:", e);
}
}
}