mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-14 05:14:28 -08:00
refactor async_calls WIP: rerender calltree
This commit is contained in:
@@ -3,7 +3,7 @@ import {el, stringify, fn_link, scrollIntoViewIfNeeded} from './domutils.js'
|
||||
import {FLAGS} from '../feature_flags.js'
|
||||
import {stringify_for_header} from './value_explorer.js'
|
||||
import {find_node} from '../ast_utils.js'
|
||||
import {is_expandable, root_calltree_node} from '../calltree.js'
|
||||
import {is_expandable, root_calltree_node, get_async_calls} from '../calltree.js'
|
||||
|
||||
// TODO perf - quadratic difficulty
|
||||
const join = arr => arr.reduce(
|
||||
@@ -170,20 +170,23 @@ export class CallTree {
|
||||
root_calltree_node(state),
|
||||
)
|
||||
|
||||
if(prev_state.async_calls != null) {
|
||||
const prev_async_calls = get_async_calls(prev_state)
|
||||
const async_calls = get_async_calls(state)
|
||||
|
||||
if(prev_async_calls != null) {
|
||||
// Expand already existing async calls
|
||||
for(let i = 0; i < prev_state.async_calls.length; i++) {
|
||||
for(let i = 0; i < prev_async_calls.length; i++) {
|
||||
this.do_render_expand_node(
|
||||
prev_state.calltree_node_is_expanded,
|
||||
state.calltree_node_is_expanded,
|
||||
prev_state.async_calls[i],
|
||||
state.async_calls[i],
|
||||
prev_async_calls[i],
|
||||
async_calls[i],
|
||||
)
|
||||
}
|
||||
// Add new async calls
|
||||
for(let i = prev_state.async_calls.length; i < state.async_calls.length; i++) {
|
||||
for(let i = prev_async_calls.length; i < async_calls.length; i++) {
|
||||
this.async_calls_root.appendChild(
|
||||
this.render_node(state.async_calls[i])
|
||||
this.render_node(async_calls[i])
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -231,7 +234,7 @@ export class CallTree {
|
||||
el('div', 'call_el',
|
||||
el('i', '', 'async calls'),
|
||||
this.async_calls_root = el('div', 'callnode',
|
||||
state.async_calls.map(call => this.render_node(call))
|
||||
get_async_calls(state).map(call => this.render_node(call))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user