Add getMyProcesses
This commit is contained in:
parent
64775af683
commit
770eedf39d
@ -662,7 +662,42 @@ export class Service {
|
|||||||
throw new Error('Failed to update process');
|
throw new Error('Failed to update process');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user