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;
|
let roles;
|
||||||
try {
|
try {
|
||||||
roles = await service.getRoles(process);
|
roles = await service.getRoles(process);
|
||||||
if (!roles) {
|
// console.log("ROLES: ", roles);
|
||||||
roles = await process.states[0].encrypted_pcd.roles;
|
|
||||||
}
|
|
||||||
console.log("ROLES: ", roles);
|
|
||||||
|
|
||||||
const hasCurrentUser = service.rolesContainsUs(roles);
|
const hasCurrentUser = service.rolesContainsUs(roles);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
let myProcessesId = new Set();
|
let processesToScan = new Set();
|
||||||
let toDownload = [];
|
let toDownload = [];
|
||||||
|
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
@ -28,7 +28,7 @@ self.addEventListener('message', async (event) => {
|
|||||||
};
|
};
|
||||||
const scanMissingData = async () => {
|
const scanMissingData = async () => {
|
||||||
console.log('Scanning for missing data...');
|
console.log('Scanning for missing data...');
|
||||||
const myProcesses = getProcesses(myProcessesId);
|
const myProcesses = getProcesses(processesToScan);
|
||||||
|
|
||||||
let toDownload = [];
|
let toDownload = [];
|
||||||
// Iterate on each process
|
// Iterate on each process
|
||||||
@ -58,12 +58,19 @@ self.addEventListener('message', async (event) => {
|
|||||||
|
|
||||||
if (data.type === 'UPDATE_PROCESSES') {
|
if (data.type === 'UPDATE_PROCESSES') {
|
||||||
try {
|
try {
|
||||||
const { processIds } = data.payload;
|
const { myProcessesId } = data.payload;
|
||||||
for (const processId of processIds) {
|
if (myProcessesId && myProcessesId.length != 0) {
|
||||||
myProcessesId.add(processId);
|
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) {
|
} catch (error) {
|
||||||
event.ports[0].postMessage({ status: 'error', message: error.message });
|
event.ports[0].postMessage({ status: 'error', message: error.message });
|
||||||
}
|
}
|
||||||
|
@ -1277,23 +1277,13 @@ export default class Services {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!lastDifferentState) {
|
if (!lastDifferentState) {
|
||||||
|
|
||||||
lastDifferentState = process.states.pop();
|
lastDifferentState = process.states.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lastDifferentState || !lastDifferentState.pcd_commitment) {
|
if (lastDifferentState && lastDifferentState.roles) {
|
||||||
|
return lastDifferentState!.roles;
|
||||||
|
} else {
|
||||||
return {};
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user