interface: integrated and tested all scries with reducer

This commit is contained in:
Logan Allen 2020-08-28 13:40:17 -05:00
parent c9bfe272e3
commit 90a6282b4e
3 changed files with 29 additions and 41 deletions

View File

@ -3,7 +3,7 @@ import { StoreState } from '../store/type';
import { Patp, Path, PatpNoSig } from '~/types/noun';
export const createPost = (contents: Object[], parentIndex: string) => {
export const createPost = (contents: Object[], parentIndex: string = '') => {
return {
author: `~${window.ship}`,
index: parentIndex + '/' + Date.now(),
@ -74,37 +74,47 @@ export default class GraphApi extends BaseApi<StoreState> {
getKeys() {
this.scry<any>('graph-store', '/keys')
.then((keys) => {
console.log(keys);
this.store.handleEvent({
data: keys
});
});
}
getTags() {
this.scry<any>('graph-store', '/tags')
.then((tags) => {
console.log(tags);
this.store.handleEvent({
data: tags
});
});
}
getTagQueries() {
this.scry<any>('graph-store', '/tag-queries')
.then((tagQueries) => {
console.log(tagQueries);
this.store.handleEvent({
data: tagQueries
});
});
}
getGraph(ship: string, resource: string) {
this.scry<any>('graph-store', `/graph/${ship}/${resource}`)
.then((graph) => {
console.log(graph);
this.store.handleEvent({
data: graph
});
});
}
getGraphSubset(ship: string, resource: string, start: string, end: start) {
this.scry<any>(
'graph-store',
`/graph-subset/${ship}/${resource}/${start}/${end}`
`/graph-subset/${ship}/${resource}/${end}/${start}`
).then((subset) => {
console.log(subset);
this.store.handleEvent({
data: subset
});
});
}
@ -113,37 +123,10 @@ export default class GraphApi extends BaseApi<StoreState> {
'graph-store',
`/node/${ship}/${resource}/${index}`
).then((node) => {
console.log(node);
this.store.handleEvent({
data: node
});
});
}
getPost(ship: string, resource: string, index: string) {
this.scry<any>(
'graph-store',
`/post/${ship}/${resource}/${index}`
).then((post) => {
console.log(post);
});
}
getNodeChildren(ship: string, resource: string, index: string) {
this.scry<any>(
'graph-store',
`/node-children/${ship}/${resource}/${index}`
).then((children) => {
console.log(children);
});
}
getNodeChildrenSubset(ship: string, resource: string,
start: string, end: string, index: string) {
this.scry<any>(
'graph-store',
`/node-children-subset/${ship}/${resource}/${start}/${end}/${index}`
).then((subset) => {
console.log(subset);
});
}
}

View File

@ -22,7 +22,13 @@ const keys = (json, state) => {
const data = _.get(json, 'keys', false);
if (data) {
state.graphKeys = new Set(data.map((res) => {
return res.ship + '/' + res.name;
let resource = res.ship + '/' + res.name;
if (!(resource in state.graphs)) {
state.graphs[resource] = new OrderedMap();
}
return resource;
}));
}
};
@ -35,9 +41,7 @@ const addGraph = (json, state) => {
}
let resource = data.resource.ship + '/' + data.resource.name;
if (!(resource in state.graphs)) {
state.graphs[resource] = new OrderedMap();
}
state.graphs[resource] = new OrderedMap();
for (let i in data.graph) {
let item = data.graph[i];

View File

@ -13,6 +13,7 @@ import { SettingsScreen } from './components/settings';
import { MessageScreen } from './components/lib/message-screen';
import { Links } from './components/links-list';
import { LinkDetail } from './components/link';
import {
makeRoutePath,
amOwnerOfGroup,