process page find its own processes and send it to worker
This commit is contained in:
parent
08e7d5daf2
commit
0649226176
@ -564,10 +564,7 @@ async function getMyProcesses(): Promise<Set<string>> {
|
||||
let roles;
|
||||
try {
|
||||
roles = await service.getRoles(process);
|
||||
if (!roles) {
|
||||
roles = await process.states[0].encrypted_pcd.roles;
|
||||
}
|
||||
console.log("ROLES: ", roles);
|
||||
// console.log("ROLES: ", roles);
|
||||
|
||||
const hasCurrentUser = service.rolesContainsUs(roles);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
let myProcessesId = new Set();
|
||||
let processesToScan = new Set();
|
||||
let toDownload = [];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
@ -28,7 +28,7 @@ self.addEventListener('message', async (event) => {
|
||||
};
|
||||
const scanMissingData = async () => {
|
||||
console.log('Scanning for missing data...');
|
||||
const myProcesses = getProcesses(myProcessesId);
|
||||
const myProcesses = getProcesses(processesToScan);
|
||||
|
||||
let toDownload = [];
|
||||
// Iterate on each process
|
||||
@ -58,12 +58,19 @@ self.addEventListener('message', async (event) => {
|
||||
|
||||
if (data.type === 'UPDATE_PROCESSES') {
|
||||
try {
|
||||
const { processIds } = data.payload;
|
||||
for (const processId of processIds) {
|
||||
myProcessesId.add(processId);
|
||||
const { myProcessesId } = data.payload;
|
||||
if (myProcessesId && myProcessesId.length != 0) {
|
||||
for (const processId of myProcessesId) {
|
||||
if (processesToScan) {
|
||||
processesToScan.add(processId);
|
||||
} else {
|
||||
throw new Error('No processesToScan');
|
||||
}
|
||||
}
|
||||
console.log(processesToScan);
|
||||
} else {
|
||||
throw new Error('Empty processIds list');
|
||||
}
|
||||
console.log(myProcessesId);
|
||||
|
||||
} catch (error) {
|
||||
event.ports[0].postMessage({ status: 'error', message: error.message });
|
||||
}
|
||||
|
@ -1277,23 +1277,13 @@ export default class Services {
|
||||
);
|
||||
|
||||
if (!lastDifferentState) {
|
||||
|
||||
lastDifferentState = process.states.pop();
|
||||
}
|
||||
|
||||
if (!lastDifferentState || !lastDifferentState.pcd_commitment) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const roles = lastDifferentState!.pcd_commitment['roles'];
|
||||
if (roles) {
|
||||
const userDiff = await this.getDiffByValue(roles);
|
||||
if (userDiff) {
|
||||
console.log("Successfully retrieved userDiff:", userDiff);
|
||||
return userDiff.new_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastDifferentState && lastDifferentState.roles) {
|
||||
return lastDifferentState!.roles;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user