interface: unpleasant changes to pending states

This commit is contained in:
Logan Allen 2021-03-09 15:00:53 -06:00
parent 731732a86e
commit 0fc7c312ab
3 changed files with 38 additions and 9 deletions

View File

@ -237,6 +237,12 @@ export default class GraphApi extends BaseApi<StoreState> {
action['add-nodes'].resource.ship =
action['add-nodes'].resource.ship.slice(1);
this.store.handleEvent({ data: {
'graph-update': action
} });
return pendingPromise;
/* TODO: stop lying to our users about pending states
return pendingPromise.then((pendingHashes) => {
for (let index in action['add-nodes'].nodes) {
action['add-nodes'].nodes[index].post.hash =
@ -250,6 +256,7 @@ export default class GraphApi extends BaseApi<StoreState> {
}
} });
});
*/
}
removeNodes(ship: Patp, name: string, indices: string[]) {

View File

@ -58,7 +58,9 @@ const addGraph = (json, state) => {
let resource = data.resource.ship + '/' + data.resource.name;
state.graphs[resource] = new BigIntOrderedMap();
state.graphHashmap[resource] = {};
state.graphHashMap[resource] = {};
state.graphTimesentMap[resource] = {};
for (let idx in data.graph) {
let item = data.graph[idx];
@ -66,7 +68,7 @@ const addGraph = (json, state) => {
let node = _processNode(item);
if (node.post.hash) {
state.graphHashmap[resource][node.post.hash] = true;
state.graphHashMap[resource][node.post.hash] = true;
}
state.graphs[resource].set(
@ -143,7 +145,7 @@ const addNodes = (json, state) => {
return graph;
};
const _removePending = (graph, post) => {
const _removePending = (graph, post, resource) => {
if (!post.hash) {
return graph;
}
@ -160,6 +162,18 @@ const addNodes = (json, state) => {
delete state.pendingIndices[post.hash];
}
if (state.graphTimesentMap[resource][post['time-sent']]) {
let index = state.graphTimesentMap[resource][post['time-sent']];
if (index.split('/').length === 0) { return; }
let indexArr = index.split('/').slice(1).map((ind) => {
return bigInt(ind);
});
graph = _remove(graph, indexArr);
delete state.graphTimesentMap[resource][post['time-sent']];
}
return graph;
};
@ -172,8 +186,12 @@ const addNodes = (json, state) => {
state.graphs[resource] = new BigIntOrderedMap();
}
if (!(resource in state.graphHashmap)) {
state.graphHashmap[resource] = {};
if (!(resource in state.graphHashMap)) {
state.graphHashMap[resource] = {};
}
if (!(resource in state.graphTimesentMap)) {
state.graphTimesentMap[resource] = {};
}
state.graphKeys.add(resource);
@ -190,7 +208,7 @@ const addNodes = (json, state) => {
indices.forEach((index) => {
let node = data.nodes[index];
graph = _removePending(graph, node.post);
graph = _removePending(graph, node.post, resource);
if (index.split('/').length === 0) { return; }
let indexArr = index.split('/').slice(1).map((ind) => {
@ -201,13 +219,16 @@ const addNodes = (json, state) => {
if (node.post.hash) {
if (node.post.pending &&
node.post.hash in state.graphHashmap[resource]) {
node.post.hash in state.graphHashMap[resource]) {
return;
}
state.graphHashmap[resource][node.post.hash] = true;
state.graphHashMap[resource][node.post.hash] = true;
}
if (node.post.pending) {
state.graphTimesentMap[resource][node.post['time-sent']] = index;
}
node.children = mapifyChildren(node?.children || {});

View File

@ -101,7 +101,8 @@ export default class GlobalStore extends BaseStore<StoreState> {
settings: {},
pendingJoin: {},
pendingIndices: {},
graphHashmap: {}
graphHashMap: {},
graphTimesentMap: {}
};
}