aboutsummaryrefslogtreecommitdiffstats
path: root/client/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/index.js')
-rw-r--r--client/src/index.js108
1 files changed, 54 insertions, 54 deletions
diff --git a/client/src/index.js b/client/src/index.js
index 0ca8b1c..f610cd4 100644
--- a/client/src/index.js
+++ b/client/src/index.js
@@ -2,7 +2,7 @@ import 'preact/debug';
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import { h, Fragment, Component, render } from 'preact';
-import { GraphContainerJSONLD, GraphContainerMastodon } from './graph';
+import { GraphContainer } from './graph';
import { Menu, Discussion, Selection } from './ui';
import { UserContainer } from './user';
@@ -82,69 +82,69 @@ class CollapseContainer extends Component {
}
}
-const graphRender = ({ loading, error, name, items }) => {
- if (loading) {
- return (
- <article>
- <div>loading...</div>
- </article>
- );
- }
-
- if (error) {
- return (
- <article>
- <h1>error loading</h1>
- <div>
- <p>{error.toString()}</p>
- <pre>
- <code>
- {error.stack}
- </code>
- </pre>
- </div>
- </article>
- );
- }
-
- return (
- <SelectionContainer render={({ selection, toggleSelected }) => (
- <>
- <CollapseContainer
- items={items}
- render={({ collapsed, toggleCollapsed }) => (
- <Discussion
- name={name}
- items={items}
- collapsed={collapsed}
- toggleCollapsed={toggleCollapsed}
- toggleSelected={toggleSelected}
- />
- )}
- />
- <Selection
- items={selection.map(id => items[id])}
- toggleSelected={toggleSelected}
- />
- </>
- )} />
- );
-};
-
const search = new URLSearchParams(window.location.search);
const graph = search.has('graph') ? search.get('graph') : 'lib/graph.json';
let app;
if (search.has('document') || search.has('note') || search.has('graph')) {
- const Container = search.has('document') ? GraphContainerJSONLD : GraphContainerMastodon;
+ const mode = search.has('document') ? "jsonld" : "mastodon";
const url = search.get('document') || search.get('note') || search.get('graph');
app = (
<UserContainer>
- <Container
+ <GraphContainer
url={url}
- render={graphRender}
- />
+ mode={mode}
+ >
+ {({ loading, error, name, items }) => {
+ if (loading) {
+ return (
+ <article>
+ <div>loading...</div>
+ </article>
+ );
+ }
+
+ if (error) {
+ return (
+ <article>
+ <h1>error loading</h1>
+ <div>
+ <p>{error.toString()}</p>
+ <pre>
+ <code>
+ {error.stack}
+ </code>
+ </pre>
+ </div>
+ </article>
+ );
+ }
+
+ return (
+ <SelectionContainer render={({ selection, toggleSelected }) => (
+ <>
+ <CollapseContainer
+ items={items}
+ render={({ collapsed, toggleCollapsed }) => (
+ <Discussion
+ name={name}
+ items={items}
+ collapsed={collapsed}
+ toggleCollapsed={toggleCollapsed}
+ toggleSelected={toggleSelected}
+ />
+ )}
+ />
+ <Selection
+ items={selection.map(id => items[id])}
+ toggleSelected={toggleSelected}
+ />
+ </>
+ )} />
+ );
+ }}
+ </GraphContainer>
</UserContainer>
);
} else {