From 6e7fd2ca95957f3b581647b206feaa4d3934b30d Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Sun, 14 Apr 2024 23:44:52 -0400 Subject: [PATCH] Add polling --- src/UI/UIWindowTaskManager.js | 19 +++++++++++++------ src/helpers.js | 18 ++++++++++++------ src/services/ProcessService.js | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/UI/UIWindowTaskManager.js b/src/UI/UIWindowTaskManager.js index f34b0ea4..7ce8def0 100644 --- a/src/UI/UIWindowTaskManager.js +++ b/src/UI/UIWindowTaskManager.js @@ -82,11 +82,9 @@ const UIWindowTaskManager = async function UIWindowTaskManager () { for ( let i=0; i < indent_level; i++ ) { const last_cell = i === indent_level - 1; - console.log('last_cell', last_cell); - console.log('last_item', last_item); Indent({ has_trunk: (last_cell && ( ! last_item )) || - (!last_cell && !parent_last_item[i]), + (!last_cell && !parent_last_item[i+1]), has_branch: last_cell }).appendTo(el); } @@ -127,6 +125,9 @@ const UIWindowTaskManager = async function UIWindowTaskManager () { if ( typeof el.el === 'function' ) el = el.el(); el_tbody.appendChild(el); return this; + }, + clear () { + el_tbody.innerHTML = ''; } }; }; @@ -159,7 +160,6 @@ const UIWindowTaskManager = async function UIWindowTaskManager () { el_taskarea.appendChild(tasktable.el()); const iter_tasks = (items, { indent_level, parent_last_item }) => { - console.log('aaah', parent_last_item); for ( let i=0 ; i < items.length; i++ ) { const row = Row(); const item = items[i]; @@ -186,9 +186,16 @@ const UIWindowTaskManager = async function UIWindowTaskManager () { } }; - const processes = [svc_process.get_init()]; + const interval = setInterval(() => { + tasktable.clear(); + const processes = [svc_process.get_init()]; + iter_tasks(processes, { indent_level: 0, parent_last_item: [] }); + }, 500) + + w.on_close = () => { + clearInterval(interval); + } - iter_tasks(processes, { indent_level: 0, parent_last_item: [] }); w_body.appendChild(el_taskarea); } diff --git a/src/helpers.js b/src/helpers.js index ab3aa0a1..2de6b02c 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1683,12 +1683,13 @@ window.launch_app = async (options)=>{ // ----------------------------------- let el_win; + let process; //------------------------------------ // Explorer //------------------------------------ if(options.name === 'explorer'){ - const process = new PseudoProcess({ + process = new PseudoProcess({ uuid, name: 'explorer', parent: options.parent_instance_id, @@ -1728,7 +1729,7 @@ window.launch_app = async (options)=>{ // All other apps //------------------------------------ else{ - const portal = new PortalProcess({ + process = new PortalProcess({ uuid, name: app_info.name, parent: options.parent_instance_id, @@ -1738,7 +1739,7 @@ window.launch_app = async (options)=>{ } }); const svc_process = globalThis.services.get('process'); - svc_process.register(portal); + svc_process.register(process); //----------------------------------- // iframe_url @@ -1887,9 +1888,14 @@ window.launch_app = async (options)=>{ } } - $(el_win).on('remove', () => { - svc_process.unregister(portal.uuid); - }); + (async () => { + const el = await el_win; + console.log('RESOV', el); + $(el).on('remove', () => { + const svc_process = globalThis.services.get('process'); + svc_process.unregister(process.uuid); + }); + })(); } window.open_item = async function(options){ diff --git a/src/services/ProcessService.js b/src/services/ProcessService.js index a06556c6..3d7c9c1a 100644 --- a/src/services/ProcessService.js +++ b/src/services/ProcessService.js @@ -53,7 +53,7 @@ export class ProcessService extends Service { this.processes_map.delete(uuid); this.processes.splice(this.processes.indexOf(process), 1); - const parent_list = this.uuid_to_treelist.get(process.parent.uuid); + const parent_list = this.uuid_to_treelist.get(process.parent); parent_list.splice(parent_list.indexOf(process), 1); const children = this.uuid_to_treelist.get(process.uuid);