mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 01:52:42 +03:00
graph-js: create lib/post and refactor
This commit is contained in:
parent
fdbf225c66
commit
fc2868abe7
18
pkg/interface/src/logic/lib/post.ts
Normal file
18
pkg/interface/src/logic/lib/post.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Post, GraphNode } from "~/types";
|
||||
|
||||
export const buntPost = (): Post => ({
|
||||
author: '',
|
||||
contents: [],
|
||||
hash: null,
|
||||
index: '',
|
||||
signatures: [],
|
||||
'time-sent': 0
|
||||
});
|
||||
|
||||
export function makeNodeMap(posts: Post[]): Record<string, GraphNode> {
|
||||
let nodes = {};
|
||||
posts.forEach((p) => {
|
||||
nodes[p.index] = { children: { empty: null }, post: p };
|
||||
});
|
||||
return nodes;
|
||||
}
|
@ -1,21 +1,5 @@
|
||||
import { Post, GraphNode, TextContent, Graph, NodeMap } from "~/types";
|
||||
|
||||
const buntPost = (): Post => ({
|
||||
author: '',
|
||||
contents: [],
|
||||
hash: null,
|
||||
index: '',
|
||||
signatures: [],
|
||||
'time-sent': 0
|
||||
});
|
||||
|
||||
export function makeNodeMap(posts: Post[]): Record<string, GraphNode> {
|
||||
let nodes = {};
|
||||
posts.forEach((p) => {
|
||||
nodes[p.index] = { children: { empty: null }, post: p };
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
import { buntPost } from '~/logic/lib/post';
|
||||
|
||||
export function newPost(
|
||||
title: string,
|
||||
|
@ -10,7 +10,7 @@ export type Content = TextContent | UrlContent | CodeContent | ReferenceContent
|
||||
export interface Post {
|
||||
author: Patp;
|
||||
contents: Content[];
|
||||
hash?: string;
|
||||
hash: string | null;
|
||||
index: string;
|
||||
pending?: boolean;
|
||||
signatures: string[];
|
||||
|
Loading…
Reference in New Issue
Block a user