mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21: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))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
10
src/effects.js
vendored
10
src/effects.js
vendored
@@ -1,6 +1,10 @@
|
||||
import {write_file} from './filesystem.js'
|
||||
import {color_file} from './color.js'
|
||||
import {root_calltree_node, calltree_node_loc} from './calltree.js'
|
||||
import {
|
||||
root_calltree_node,
|
||||
calltree_node_loc,
|
||||
get_async_calls
|
||||
} from './calltree.js'
|
||||
import {FLAGS} from './feature_flags.js'
|
||||
import {exec} from './index.js'
|
||||
|
||||
@@ -173,7 +177,7 @@ export const render_common_side_effects = (prev, next, command, ui) => {
|
||||
ui.editor.unembed_value_explorer()
|
||||
} else {
|
||||
|
||||
if(prev.async_calls == null && next.async_calls != null) {
|
||||
if(get_async_calls(prev) == null && get_async_calls(next) != null) {
|
||||
ui.calltree.render_async_calls(next)
|
||||
}
|
||||
|
||||
@@ -181,8 +185,6 @@ export const render_common_side_effects = (prev, next, command, ui) => {
|
||||
prev.calltree != next.calltree
|
||||
||
|
||||
prev.calltree_node_is_expanded != next.calltree_node_is_expanded
|
||||
||
|
||||
prev.async_calls != next.async_calls
|
||||
) {
|
||||
ui.calltree.render_expand_node(prev, next)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user