interface: beginnings of api/reducer integration

This commit is contained in:
Logan Allen 2021-02-26 16:59:13 -06:00
parent b2ef9044a6
commit 7c18df399c
5 changed files with 26 additions and 8 deletions

View File

@ -53,7 +53,7 @@
to+(uf ~ (mu dejs:resource))
==
::
++ pending-indices (op ;~(pfix fas (more fas dem)) nu)
++ pending-indices (op nu ;~(pfix fas (more fas dem)))
:: NOTE: move these functions to zuse
++ nu :: parse number as hex
|= jon=json
@ -79,7 +79,7 @@
%+ frond %pending-indices
:- %a
%+ turn ~(tap by pending.act)
|= [i=index:store h=hash:store]
|= [h=hash:store i=index:store]
%- pairs
:~ [%index (index i)]
[%hash s+(scot %ux h)]

View File

@ -42,7 +42,7 @@
[%groupify rid=resource to=(unit resource)]
[%forward rid=resource =update:store]
[%eval =cord]
[%pending-indices pending=(map index:store hash:store)]
[%pending-indices pending=(map hash:store index:store)]
==
--

View File

@ -108,11 +108,11 @@
::
++ nodes-to-pending-indices
|= nodes=(map index:store node:store)
^- (map index:store hash:store)
%- ~(gas by *(map index:store hash:store))
^- (map hash:store index:store)
%- ~(gas by *(map hash:store index:store))
%+ turn ~(tap by nodes)
|= [=index:store =node:store]
^- [index:store hash:store]
^- [hash:store index:store]
?> ?=(^ hash.post.node)
[index u.hash.post.node]
[u.hash.post.node index]
--

View File

@ -192,6 +192,15 @@ export default class GraphApi extends BaseApi<StoreState> {
});
}
addHashedNodes(action: Object) {
return this.spider(
'graph-update',
'graph-view-action',
'graph-add-nodes',
action
);
}
addGraph(ship: Patp, name: string, graph: any, mark: any) {
return this.storeAction({
'add-graph': {
@ -226,7 +235,12 @@ export default class GraphApi extends BaseApi<StoreState> {
}
};
const promise = this.hookAction(ship, action);
// TODO: send a request to the -graph-add-nodes thread and wait for its return
// once it returns, it should give us a { pending: {'/1': '0x.239823'} }
// then, mark those pending nodes with their corresponding hash
// and store the pending map we were given
//const promise = this.hookAction(ship, action);
const promise = this.addHashedNodes(action);
markPending(action['add-nodes'].nodes);
action['add-nodes'].resource.ship = action['add-nodes'].resource.ship.slice(1);
console.log(action);

View File

@ -123,6 +123,10 @@ const addNodes = (json, state) => {
}
state.graphKeys.add(resource);
// TODO:
// check if any of these hashes already exist. if they do, delete the
// old index before adding
for (let index in data.nodes) {
let node = data.nodes[index];
if (index.split('/').length === 0) { return; }