diff options
| author | s-ol <s+removethis@s-ol.nu> | 2022-01-24 11:12:22 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2022-01-24 11:12:22 +0000 |
| commit | eb1e149f1e53aba3abce645a3d7fc982333f3956 (patch) | |
| tree | aec938d23b379fd93eacf636e421429060e41b45 /client/src/index.js | |
| parent | server: ActivityStreams reply/link/unlink API (diff) | |
| download | fedidag-main.tar.gz fedidag-main.zip | |
Diffstat (limited to '')
| -rw-r--r-- | client/src/index.js | 108 |
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 { |
