mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 10:02:47 +03:00
graph-update: fix recursive add-nodes case
This commit is contained in:
parent
27f2f93cc8
commit
4f6003fd24
@ -105,7 +105,7 @@ const removeGraph = (json, state: GraphState): GraphState => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const mapifyChildren = (children) => {
|
const mapifyChildren = (children) => {
|
||||||
return new BigIntOrderedMap(
|
return new BigIntOrderedMap().gas(
|
||||||
_.map(children, (node, idx) => {
|
_.map(children, (node, idx) => {
|
||||||
idx = idx && idx.startsWith('/') ? idx.slice(1) : idx;
|
idx = idx && idx.startsWith('/') ? idx.slice(1) : idx;
|
||||||
const nd = {...node, children: mapifyChildren(node.children || {}) };
|
const nd = {...node, children: mapifyChildren(node.children || {}) };
|
||||||
@ -214,12 +214,14 @@ const addNodes = (json, state) => {
|
|||||||
state.graphTimesentMap[resource][node.post['time-sent']] = index;
|
state.graphTimesentMap[resource][node.post['time-sent']] = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
node.children = mapifyChildren(node?.children || {});
|
|
||||||
|
|
||||||
state.graphs[resource] = _addNode(
|
state.graphs[resource] = _addNode(
|
||||||
state.graphs[resource],
|
state.graphs[resource],
|
||||||
indexArr,
|
indexArr,
|
||||||
node
|
produce(node, draft => {
|
||||||
|
draft.children = mapifyChildren(draft?.children || {});
|
||||||
|
})
|
||||||
);
|
);
|
||||||
if(newSize !== old) {
|
if(newSize !== old) {
|
||||||
console.log(`${resource}, (${old}, ${newSize}, ${state.graphs[resource].size})`);
|
console.log(`${resource}, (${old}, ${newSize}, ${state.graphs[resource].size})`);
|
||||||
|
@ -432,7 +432,6 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
|||||||
? this.savedDistance + ref.offsetTop
|
? this.savedDistance + ref.offsetTop
|
||||||
: this.window.scrollHeight - ref.offsetTop - this.savedDistance;
|
: this.window.scrollHeight - ref.offsetTop - this.savedDistance;
|
||||||
|
|
||||||
console.log(ref.offsetTop);
|
|
||||||
|
|
||||||
this.window.scrollTo(0, newScrollTop);
|
this.window.scrollTo(0, newScrollTop);
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
@ -484,7 +483,6 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
|||||||
let bottomIndex = visibleItems[visibleItems.length - 1];
|
let bottomIndex = visibleItems[visibleItems.length - 1];
|
||||||
const { scrollTop, scrollHeight } = this.window;
|
const { scrollTop, scrollHeight } = this.window;
|
||||||
const topSpacing = this.props.origin === 'top' ? scrollTop : scrollHeight - scrollTop;
|
const topSpacing = this.props.origin === 'top' ? scrollTop : scrollHeight - scrollTop;
|
||||||
console.log(scrollTop);
|
|
||||||
const items = this.props.origin === 'top' ? visibleItems : [...visibleItems].reverse();
|
const items = this.props.origin === 'top' ? visibleItems : [...visibleItems].reverse();
|
||||||
items.forEach((index) => {
|
items.forEach((index) => {
|
||||||
const el = this.childRefs.get(index.toString());
|
const el = this.childRefs.get(index.toString());
|
||||||
@ -505,9 +503,7 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.savedIndex = bottomIndex;
|
this.savedIndex = bottomIndex;
|
||||||
console.log(this.childRefs.size);
|
|
||||||
const ref = this.childRefs.get(bottomIndex.toString())!;
|
const ref = this.childRefs.get(bottomIndex.toString())!;
|
||||||
console.log(ref);
|
|
||||||
const { offsetTop } = ref;
|
const { offsetTop } = ref;
|
||||||
this.savedDistance = topSpacing - offsetTop
|
this.savedDistance = topSpacing - offsetTop
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user