DM: pending states

This commit is contained in:
Liam Fitzgerald 2021-05-21 10:22:06 +10:00
parent 60ed7d6151
commit 65c8f30124
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 13 additions and 3 deletions

View File

@ -6,6 +6,9 @@ import { decToUd, deSig, resourceAsPath, unixToDa } from '~/logic/lib/util';
import { makeResource, resourceFromPath } from '../lib/group';
import { StoreState } from '../store/type';
import BaseApi from './base';
import {doOptimistically} from '../state/base';
import useGraphState from '../state/graph';
import { addNodes } from '../reducers/graph-update';
export const createBlankNodeWithChildPost = (
parentIndex = '',
@ -204,7 +207,7 @@ export default class GraphApi extends BaseApi<StoreState> {
addDmMessage(ship: Patp, contents: Content[]) {
const post = createPost(contents, `/${patp2dec(ship)}`)
return this.action('dm-hook', 'graph-update-2', {
const action = {
"add-nodes": {
resource: { ship: `~${window.ship}`, name: 'dm-inbox' },
nodes: {
@ -214,7 +217,14 @@ export default class GraphApi extends BaseApi<StoreState> {
}
}
}
});
}
this.action('dm-hook', 'graph-update-2', action);
markPending(action['add-nodes'].nodes);
action['add-nodes'].resource.ship =
action['add-nodes'].resource.ship.slice(1);
this.store.handleEvent({ data: {
'graph-update': action
} });
}
acceptDm(ship: Patp) {

View File

@ -142,7 +142,7 @@ const mapifyChildren = (children) => {
}));
};
const addNodes = (json, state) => {
export const addNodes = (json, state) => {
const _addNode = (graph, index, node) => {
// set child of graph
if (index.length === 1) {