mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 21:12:56 +03:00
graph-update: sort indices correctly
This commit is contained in:
parent
d17779972f
commit
6720074228
@ -109,7 +109,7 @@ const addNodes = (json, state) => {
|
|||||||
let parNode = graph.get(index[0]);
|
let parNode = graph.get(index[0]);
|
||||||
if (!parNode) {
|
if (!parNode) {
|
||||||
console.error('parent node does not exist, cannot add child');
|
console.error('parent node does not exist, cannot add child');
|
||||||
return;
|
return graph;
|
||||||
}
|
}
|
||||||
parNode.children = _addNode(parNode.children, index.slice(1), node);
|
parNode.children = _addNode(parNode.children, index.slice(1), node);
|
||||||
graph.set(index[0], parNode);
|
graph.set(index[0], parNode);
|
||||||
@ -134,7 +134,7 @@ const addNodes = (json, state) => {
|
|||||||
if (state.graphTimesentMap[resource][timestamp]) {
|
if (state.graphTimesentMap[resource][timestamp]) {
|
||||||
let index = state.graphTimesentMap[resource][timestamp];
|
let index = state.graphTimesentMap[resource][timestamp];
|
||||||
|
|
||||||
if (index.split('/').length === 0) { return; }
|
if (index.split('/').length === 0) { return graph; }
|
||||||
let indexArr = index.split('/').slice(1).map((ind) => {
|
let indexArr = index.split('/').slice(1).map((ind) => {
|
||||||
return bigInt(ind);
|
return bigInt(ind);
|
||||||
});
|
});
|
||||||
@ -178,7 +178,7 @@ const addNodes = (json, state) => {
|
|||||||
indices.sort((a, b) => {
|
indices.sort((a, b) => {
|
||||||
let aArr = a.split('/');
|
let aArr = a.split('/');
|
||||||
let bArr = b.split('/');
|
let bArr = b.split('/');
|
||||||
return bArr.length < aArr.length;
|
return aArr.length - bArr.length;
|
||||||
});
|
});
|
||||||
|
|
||||||
let graph = state.graphs[resource];
|
let graph = state.graphs[resource];
|
||||||
|
Loading…
Reference in New Issue
Block a user