publish: fix breakage from merge

This commit is contained in:
Liam Fitzgerald 2020-10-01 11:15:46 +10:00
parent ef7bb37f8f
commit 6264091148
12 changed files with 36 additions and 55 deletions

View File

@ -1,8 +1,4 @@
<<<<<<< HEAD
/- *group
=======
/- *group, store=graph-store /- *group, store=graph-store
>>>>>>> release/next-userspace
/+ resource /+ resource
^? ^?
|% |%
@ -12,12 +8,6 @@
$% [%group rid=resource] $% [%group rid=resource]
[%policy =policy] [%policy =policy]
== ==
<<<<<<< HEAD
:: $app: An app that is associated to a graph-store mark
::
+$ app-name ?(%chat %publish %links)
=======
>>>>>>> release/next-userspace
:: ::
:: $error: An error from a graph-view poke :: $error: An error from a graph-view poke
:: ::
@ -41,16 +31,6 @@
rid=resource rid=resource
title=@t title=@t
description=@t description=@t
<<<<<<< HEAD
app=app-name
=associated
==
[%delete rid=resource]
[%leave rid=resource]
[%join rid=resource =ship app=app-name]
::[%invite rid=resource ships=(set ship)]
[%groupify rid=resource app=app-name to=(unit resource)]
=======
mark=(unit mark) mark=(unit mark)
=associated =associated
module=@t module=@t
@ -61,7 +41,6 @@
::[%invite rid=resource ships=(set ship)] ::[%invite rid=resource ships=(set ship)]
[%groupify rid=resource to=(unit resource)] [%groupify rid=resource to=(unit resource)]
[%forward rid=resource =update:store] [%forward rid=resource =update:store]
>>>>>>> release/next-userspace
== ==
-- --

View File

@ -138,7 +138,7 @@ export default class GraphApi extends BaseApi<StoreState> {
} }
addNodes(ship: Patp, name: string, nodes: Object) { addNodes(ship: Patp, name: string, nodes: Object) {
this.hookAction(ship, { return this.hookAction(ship, {
'add-nodes': { 'add-nodes': {
resource: { ship, name }, resource: { ship, name },
nodes nodes

View File

@ -39,7 +39,7 @@ export interface StoreState {
permissions: Permissions; permissions: Permissions;
s3: S3State; s3: S3State;
graphs: Graphs; graphs: Graphs;
graphKeys: Set<String>; graphKeys: Set<string>;
// App specific states // App specific states

View File

@ -18,7 +18,7 @@ export type Serial = string;
export type Jug<K,V> = Map<K,Set<V>>; export type Jug<K,V> = Map<K,Set<V>>;
// name of app // name of app
export type AppName = 'chat' | 'link' | 'contacts' | 'publish'; export type AppName = 'chat' | 'link' | 'contacts' | 'publish' | 'graph';
export function getTagFromFrond<O>(frond: O): keyof O { export function getTagFromFrond<O>(frond: O): keyof O {
const tags = Object.keys(frond) as Array<keyof O>; const tags = Object.keys(frond) as Array<keyof O>;

View File

@ -71,13 +71,13 @@ export default function PublishApp(props: PublishAppProps) {
? "sidebar" ? "sidebar"
: "rightPanel"; : "rightPanel";
const appAssociations = props.associations?.publish || {}; const appAssociations = props.associations?.graph || {};
const graphs = props.graphs || {} const graphs = props.graphs || {}
return ( return (
<> <>
<Helmet defer={false}> <Helmet>
<title>{unreadTotal > 0 ? `(${unreadTotal}) ` : ""}OS1 - Publish</title> <title>OS1 - Publish</title>
</Helmet> </Helmet>
<Route <Route
path={[ path={[
@ -88,7 +88,6 @@ export default function PublishApp(props: PublishAppProps) {
]} ]}
> >
<RouterSkeleton <RouterSkeleton
popout={location.pathname.includes("popout/")}
active={active} active={active}
sidebarShown={sidebarShown} sidebarShown={sidebarShown}
invites={invites} invites={invites}
@ -97,6 +96,7 @@ export default function PublishApp(props: PublishAppProps) {
associations={associations} associations={associations}
contacts={contacts} contacts={contacts}
api={api} api={api}
graphKeys={props.graphKeys}
> >
<Switch> <Switch>
<Route exact path="/~publish"> <Route exact path="/~publish">
@ -156,10 +156,10 @@ export default function PublishApp(props: PublishAppProps) {
const notebookContacts = const notebookContacts =
bookGroupPath in contacts ? contacts[bookGroupPath] : {}; bookGroupPath in contacts ? contacts[bookGroupPath] : {};
const notebook = notebooks?.[ship]?.[book]; const graph = graphs[`${ship.slice(1)}/${book}`];
return ( return (
<NotebookRoutes <NotebookRoutes
notebook={notebook}
ship={ship} ship={ship}
book={book} book={book}
groups={groups} groups={groups}
@ -168,12 +168,11 @@ export default function PublishApp(props: PublishAppProps) {
association={association} association={association}
associations={associations} associations={associations}
graphs={graphs} graphs={graphs}
sidebarShown={sidebarShown}
api={api} api={api}
hideNicknames={hideNicknames} hideNicknames={hideNicknames}
hideAvatars={hideAvatars} hideAvatars={hideAvatars}
remoteContentPolicy={remoteContentPolicy} remoteContentPolicy={remoteContentPolicy}
associations={associations} graph={graph}
{...props} {...props}
/> />
); );

View File

@ -34,7 +34,7 @@ export function EditPost(props: EditPostProps & RouteComponentProps) {
const nodes = editPost(newRev, noteId, title, body); const nodes = editPost(newRev, noteId, title, body);
await api.graph.addNodes(ship, book, nodes); await api.graph.addNodes(ship, book, nodes);
await waiter(p => { await waiter(p => {
const [rev] = getLatestRevision(note); const [rev] = getLatestRevision(p.note);
return rev === newRev; return rev === newRev;
}); });
history.push(`/~publish/notebook/ship/${ship}/${book}/note/${noteId}`); history.push(`/~publish/notebook/ship/${ship}/${book}/note/${noteId}`);

View File

@ -34,7 +34,7 @@ function NavigationItem(props: {
function getAdjacentId(graph: Graph, child: number, backwards = false): number | null { function getAdjacentId(graph: Graph, child: number, backwards = false): number | null {
const children = Array.from(graph); const children = Array.from(graph);
const i = children.findIndex(([index]) => index === child); const i = children.findIndex(([index]) => index === child);
const target = children[backwards ? i-1 : i+1]; const target = children[backwards ? i+1 : i-1];
return target?.[0] || null; return target?.[0] || null;
} }

View File

@ -12,7 +12,7 @@ import { Groups } from "~/types/group-update";
import { Contacts, Rolodex } from "~/types/contact-update"; import { Contacts, Rolodex } from "~/types/contact-update";
import GlobalApi from "~/logic/api/global"; import GlobalApi from "~/logic/api/global";
import styled from "styled-components"; import styled from "styled-components";
import { Associations } from "~/types"; import { Associations, Graph, Association } from "~/types";
import { deSig } from "~/logic/lib/util"; import { deSig } from "~/logic/lib/util";
interface NotebookProps { interface NotebookProps {
@ -55,16 +55,18 @@ export class Notebook extends PureComponent<
api, api,
ship, ship,
book, book,
notebook,
notebookContacts, notebookContacts,
groups, groups,
history, history,
hideNicknames, hideNicknames,
associations, associations,
association,
graph
} = this.props; } = this.props;
const { state } = this; const { state } = this;
const { metadata } = association;
const group = groups[notebook?.["writers-group-path"]]; const group = groups[association?.['group-path']];
if (!group) return null; // Waitin on groups to populate if (!group) return null; // Waitin on groups to populate
const contact = notebookContacts[ship]; const contact = notebookContacts[ship];
@ -75,8 +77,6 @@ export class Notebook extends PureComponent<
const isWriter = const isWriter =
isOwn || group.tags?.publish?.[`writers-${book}`]?.has(window.ship); isOwn || group.tags?.publish?.[`writers-${book}`]?.has(window.ship);
const notesList = notebook?.["notes-by-date"] || [];
const notes = notebook?.notes || {};
const showNickname = contact?.nickname && !hideNicknames; const showNickname = contact?.nickname && !hideNicknames;
return ( return (
@ -94,7 +94,7 @@ export class Notebook extends PureComponent<
<Link to="/~publish">{"<- All Notebooks"}</Link> <Link to="/~publish">{"<- All Notebooks"}</Link>
</Box> </Box>
<Box> <Box>
<Text> {notebook?.title}</Text> <Text> {metadata?.title}</Text>
<br /> <br />
<Text color="lightGray">by </Text> <Text color="lightGray">by </Text>
<Text fontFamily={showNickname ? "sans" : "mono"}> <Text fontFamily={showNickname ? "sans" : "mono"}>
@ -103,7 +103,7 @@ export class Notebook extends PureComponent<
</Box> </Box>
<Row justifyContent={["flex-start", "flex-end"]}> <Row justifyContent={["flex-start", "flex-end"]}>
{isWriter && ( {isWriter && (
<Link to={`/~publish/notebook/${ship}/${book}/new`}> <Link to={`/~publish/notebook/ship/${ship}/${book}/new`}>
<Button primary>New Post</Button> <Button primary>New Post</Button>
</Link> </Link>
)} )}
@ -120,8 +120,8 @@ export class Notebook extends PureComponent<
destructive destructive
onClick={() => { onClick={() => {
this.setState({ isUnsubscribing: true }); this.setState({ isUnsubscribing: true });
api.publish
.unsubscribeNotebook(deSig(ship), book) api.graph.leaveGraph(ship, book)
.then(() => { .then(() => {
history.push("/~publish"); history.push("/~publish");
}) })
@ -168,8 +168,7 @@ export class Notebook extends PureComponent<
</Tabs> </Tabs>
{state.tab === "all" && ( {state.tab === "all" && (
<NotebookPosts <NotebookPosts
notes={notes} graph={graph}
list={notesList}
host={ship} host={ship}
book={book} book={book}
contacts={notebookContacts} contacts={notebookContacts}
@ -178,16 +177,17 @@ export class Notebook extends PureComponent<
)} )}
{state.tab === "about" && ( {state.tab === "about" && (
<Box mt="3" color="black"> <Box mt="3" color="black">
{notebook?.about} {metadata?.description}
</Box> </Box>
)} )}
{state.tab === "subscribers" && ( {state.tab === "subscribers" && (
<Subscribers <Subscribers
host={ship}
book={book} book={book}
notebook={notebook}
api={api} api={api}
groups={groups} groups={groups}
associations={associations}
association={association}
contacts={{}}
/> />
)} )}
{state.tab === "settings" && ( {state.tab === "settings" && (
@ -195,9 +195,9 @@ export class Notebook extends PureComponent<
host={ship} host={ship}
book={book} book={book}
api={api} api={api}
notebook={notebook}
contacts={notebookContacts} contacts={notebookContacts}
associations={associations} associations={associations}
association={association}
groups={groups} groups={groups}
/> />
)} )}

View File

@ -25,14 +25,14 @@ export function Sidebar(props: any) {
? alphabetiseAssociations(props.associations.contacts) ? alphabetiseAssociations(props.associations.contacts)
: {}; : {};
const appAssociations = const appAssociations =
props.associations && "publish" in props.associations props.associations && "graph" in props.associations
? props.associations.publish ? props.associations.graph
: {}; : {};
const groups = props.groups || {}; const groups = props.groups || {};
const groupedItems = _.chain(props.graphs) const groupedItems = _.chain(Array.from(props.graphKeys))
.reduce((acc, g, path) => { .reduce((acc, path) => {
const appPath = `/ship/~${path}`; const appPath = `/ship/~${path}`;
return appPath in appAssociations return appPath in appAssociations
? [...acc, appAssociations[appPath]] ? [...acc, appAssociations[appPath]]

View File

@ -30,6 +30,7 @@ export default function NewPost(props: NewPostProps & RouteComponentProps) {
try { try {
const [noteId, nodes] = newPost(title, body) const [noteId, nodes] = newPost(title, body)
await api.graph.addNodes(ship, book, nodes) await api.graph.addNodes(ship, book, nodes)
await waiter(p => p.graph.has(noteId));
history.push(`/~publish/notebook/ship/${ship}/${book}/note/${noteId}`); history.push(`/~publish/notebook/ship/${ship}/${book}/note/${noteId}`);
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View File

@ -44,16 +44,16 @@ export function NewScreen(props: NewScreenProps & RouteComponentProps) {
bookId, bookId,
name, name,
description, description,
group,
"publish", "publish",
group
); );
} else { } else {
await props.api.graph.createUnmanagedGraph( await props.api.graph.createUnmanagedGraph(
bookId, bookId,
name, name,
description, description,
{ open: { banned: [], banRanks: [] } },
"publish", "publish",
{ open: { banned: [], banRanks: [] } }
); );
} }

View File

@ -20,6 +20,7 @@ type SkeletonProps = RouteComponentProps<{
associations: Associations; associations: Associations;
contacts: Rolodex; contacts: Rolodex;
graphs: Graphs; graphs: Graphs;
graphKeys: Set<string>;
api: GlobalApi; api: GlobalApi;
children: React.ReactNode; children: React.ReactNode;
}; };
@ -90,6 +91,7 @@ export function Skeleton(props: SkeletonProps) {
<Sidebar <Sidebar
notebooks={props.notebooks} notebooks={props.notebooks}
graphs={props.graphs} graphs={props.graphs}
graphKeys={props.graphKeys}
contacts={props.contacts} contacts={props.contacts}
path={path} path={path}
hidden={hideSidebar} hidden={hideSidebar}