diff --git a/src/pages/process/process.ts b/src/pages/process/process.ts index a7f5306..728b129 100755 --- a/src/pages/process/process.ts +++ b/src/pages/process/process.ts @@ -164,9 +164,8 @@ async function populateAutocompleteList(select: HTMLSelectElement, query: string let options_to_show = []; const service = await Services.getInstance(); - const myProcesses = await service.getMyProcesses(); + const mineArray = await service.getMyProcesses(); const allProcesses = new Set(Object.keys(await service.getProcesses())); - const mineArray = Array.from(myProcesses); const allArray = Array.from(allProcesses.difference(myProcesses)); const wrapper = select.parentNode; diff --git a/src/router.ts b/src/router.ts index f55528e..71f8840 100755 --- a/src/router.ts +++ b/src/router.ts @@ -146,11 +146,6 @@ export async function init(): Promise { } await services.restoreProcessesFromDB(); await services.restoreSecretsFromDB(); - setTimeout(async () => { - const myProcesses = await services.getMyProcesses(); - const db = await Database.getInstance(); - await db.updateMyProcesses(myProcesses); - }, 200); if (services.isPaired()) { await navigate('process'); diff --git a/src/services/service.ts b/src/services/service.ts index d734d47..851eb9a 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -534,16 +534,6 @@ export default class Services { } } - public async updateProcessesWorker() { - try { - const myProcesses = await this.getMyProcesses(); - const db = await Database.getInstance(); - await db.updateMyProcesses(myProcesses); - } catch (e) { - console.error('Failed to update processes worker:', e); - } - } - public async handleApiReturn(apiReturn: ApiReturn) { console.log(apiReturn); if (apiReturn.new_tx_to_send && apiReturn.new_tx_to_send.transaction.length != 0) { @@ -601,14 +591,6 @@ export default class Services { // Save process to db await this.saveProcessToDb(processId, updatedProcess.current_process); - setTimeout(async () => { - try { - await this.updateProcessesWorker(); - } catch (e) { - console.error(e); - } - }, 0) - const isPaired = this.isPaired(); if (updatedProcess.diffs && updatedProcess.diffs.length != 0) { @@ -1135,8 +1117,6 @@ export default class Services { for (const [processId, process] of Object.entries(newProcesses)) { const existing = await this.getProcess(processId); if (existing) { - console.log(`${processId} already in db`); - const event = new CustomEvent('process-updated', { detail: { processId } }); @@ -1152,7 +1132,6 @@ export default class Services { await this.saveProcessToDb(processId, process as Process); } } - await this.updateProcessesWorker(); } }, 500) } catch (e) { @@ -1193,15 +1172,13 @@ export default class Services { } } - async getMyProcesses(): Promise> { + public async getMyProcesses(): Promise { try { const processes = await this.getProcesses(); - const userProcessSet = new Set(); 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 { @@ -1209,13 +1186,12 @@ export default class Services { if (this.rolesContainsUs(roles)) { this.myProcesses.add(processId); - userProcessSet.add(processId); } } catch (e) { console.error(e); } } - return userProcessSet; + return Array.from(this.myProcesses); } catch (e) { console.error("Failed to get processes:", e); }