mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 01:52:42 +03:00
interface: unpleasant changes to pending states
This commit is contained in:
parent
731732a86e
commit
0fc7c312ab
@ -237,6 +237,12 @@ export default class GraphApi extends BaseApi<StoreState> {
|
|||||||
action['add-nodes'].resource.ship =
|
action['add-nodes'].resource.ship =
|
||||||
action['add-nodes'].resource.ship.slice(1);
|
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) => {
|
return pendingPromise.then((pendingHashes) => {
|
||||||
for (let index in action['add-nodes'].nodes) {
|
for (let index in action['add-nodes'].nodes) {
|
||||||
action['add-nodes'].nodes[index].post.hash =
|
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[]) {
|
removeNodes(ship: Patp, name: string, indices: string[]) {
|
||||||
|
@ -58,7 +58,9 @@ const addGraph = (json, state) => {
|
|||||||
|
|
||||||
let resource = data.resource.ship + '/' + data.resource.name;
|
let resource = data.resource.ship + '/' + data.resource.name;
|
||||||
state.graphs[resource] = new BigIntOrderedMap();
|
state.graphs[resource] = new BigIntOrderedMap();
|
||||||
state.graphHashmap[resource] = {};
|
state.graphHashMap[resource] = {};
|
||||||
|
state.graphTimesentMap[resource] = {};
|
||||||
|
|
||||||
|
|
||||||
for (let idx in data.graph) {
|
for (let idx in data.graph) {
|
||||||
let item = data.graph[idx];
|
let item = data.graph[idx];
|
||||||
@ -66,7 +68,7 @@ const addGraph = (json, state) => {
|
|||||||
|
|
||||||
let node = _processNode(item);
|
let node = _processNode(item);
|
||||||
if (node.post.hash) {
|
if (node.post.hash) {
|
||||||
state.graphHashmap[resource][node.post.hash] = true;
|
state.graphHashMap[resource][node.post.hash] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.graphs[resource].set(
|
state.graphs[resource].set(
|
||||||
@ -143,7 +145,7 @@ const addNodes = (json, state) => {
|
|||||||
return graph;
|
return graph;
|
||||||
};
|
};
|
||||||
|
|
||||||
const _removePending = (graph, post) => {
|
const _removePending = (graph, post, resource) => {
|
||||||
if (!post.hash) {
|
if (!post.hash) {
|
||||||
return graph;
|
return graph;
|
||||||
}
|
}
|
||||||
@ -160,6 +162,18 @@ const addNodes = (json, state) => {
|
|||||||
delete state.pendingIndices[post.hash];
|
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;
|
return graph;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,8 +186,12 @@ const addNodes = (json, state) => {
|
|||||||
state.graphs[resource] = new BigIntOrderedMap();
|
state.graphs[resource] = new BigIntOrderedMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(resource in state.graphHashmap)) {
|
if (!(resource in state.graphHashMap)) {
|
||||||
state.graphHashmap[resource] = {};
|
state.graphHashMap[resource] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(resource in state.graphTimesentMap)) {
|
||||||
|
state.graphTimesentMap[resource] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
state.graphKeys.add(resource);
|
state.graphKeys.add(resource);
|
||||||
@ -190,7 +208,7 @@ const addNodes = (json, state) => {
|
|||||||
|
|
||||||
indices.forEach((index) => {
|
indices.forEach((index) => {
|
||||||
let node = data.nodes[index];
|
let node = data.nodes[index];
|
||||||
graph = _removePending(graph, node.post);
|
graph = _removePending(graph, node.post, resource);
|
||||||
|
|
||||||
if (index.split('/').length === 0) { return; }
|
if (index.split('/').length === 0) { return; }
|
||||||
let indexArr = index.split('/').slice(1).map((ind) => {
|
let indexArr = index.split('/').slice(1).map((ind) => {
|
||||||
@ -201,13 +219,16 @@ const addNodes = (json, state) => {
|
|||||||
|
|
||||||
if (node.post.hash) {
|
if (node.post.hash) {
|
||||||
if (node.post.pending &&
|
if (node.post.pending &&
|
||||||
node.post.hash in state.graphHashmap[resource]) {
|
node.post.hash in state.graphHashMap[resource]) {
|
||||||
return;
|
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 || {});
|
node.children = mapifyChildren(node?.children || {});
|
||||||
|
|
||||||
|
@ -101,7 +101,8 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
|||||||
settings: {},
|
settings: {},
|
||||||
pendingJoin: {},
|
pendingJoin: {},
|
||||||
pendingIndices: {},
|
pendingIndices: {},
|
||||||
graphHashmap: {}
|
graphHashMap: {},
|
||||||
|
graphTimesentMap: {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user