graph-update: fix recursive add-nodes case

This commit is contained in:
Liam Fitzgerald 2021-04-27 16:32:05 +10:00
parent 27f2f93cc8
commit 4f6003fd24
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 5 additions and 7 deletions

View File

@ -105,7 +105,7 @@ const removeGraph = (json, state: GraphState): GraphState => {
};
const mapifyChildren = (children) => {
return new BigIntOrderedMap(
return new BigIntOrderedMap().gas(
_.map(children, (node, idx) => {
idx = idx && idx.startsWith('/') ? idx.slice(1) : idx;
const nd = {...node, children: mapifyChildren(node.children || {}) };
@ -214,12 +214,14 @@ const addNodes = (json, state) => {
state.graphTimesentMap[resource][node.post['time-sent']] = index;
}
node.children = mapifyChildren(node?.children || {});
state.graphs[resource] = _addNode(
state.graphs[resource],
indexArr,
node
produce(node, draft => {
draft.children = mapifyChildren(draft?.children || {});
})
);
if(newSize !== old) {
console.log(`${resource}, (${old}, ${newSize}, ${state.graphs[resource].size})`);

View File

@ -432,7 +432,6 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
? this.savedDistance + ref.offsetTop
: this.window.scrollHeight - ref.offsetTop - this.savedDistance;
console.log(ref.offsetTop);
this.window.scrollTo(0, newScrollTop);
requestAnimationFrame(() => {
@ -484,7 +483,6 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
let bottomIndex = visibleItems[visibleItems.length - 1];
const { scrollTop, scrollHeight } = this.window;
const topSpacing = this.props.origin === 'top' ? scrollTop : scrollHeight - scrollTop;
console.log(scrollTop);
const items = this.props.origin === 'top' ? visibleItems : [...visibleItems].reverse();
items.forEach((index) => {
const el = this.childRefs.get(index.toString());
@ -505,9 +503,7 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
}
this.savedIndex = bottomIndex;
console.log(this.childRefs.size);
const ref = this.childRefs.get(bottomIndex.toString())!;
console.log(ref);
const { offsetTop } = ref;
this.savedDistance = topSpacing - offsetTop
}