aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/App.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/App.js')
-rw-r--r--vnext/src/App.js36
1 files changed, 15 insertions, 21 deletions
diff --git a/vnext/src/App.js b/vnext/src/App.js
index 4e235c46..15e29017 100644
--- a/vnext/src/App.js
+++ b/vnext/src/App.js
@@ -18,6 +18,7 @@ import Login from './ui/Login';
import { useCookies } from 'react-cookie';
import { me, trends } from './api';
+import { useVisitor } from './ui/VisitorContext';
/**
*
@@ -32,6 +33,8 @@ export default function App({ footer }) {
const [allTrends, setAllTrends] = useState([]);
+ const [visitor, setVisitor] = useVisitor();
+
useEffect(() => {
svg4everybody();
let params = qs.parse(window.location.search.substring(1));
@@ -42,15 +45,6 @@ export default function App({ footer }) {
}
}, [setCookie, footer]);
- /**
- * @type {import('./api').SecureUser}
- */
- const unknownUser = {
- uid: -1
- };
-
- const [visitor, setVisitor] = useState(unknownUser);
-
let updateStatus = () => {
// refresh server visitor state (unread counters)
me().then(visitor => {
@@ -116,7 +110,7 @@ export default function App({ footer }) {
};
return (
<>
- <Header visitor={visitor} />
+ <Header />
<div id="content_wrapper">
{
<aside id="sidebar">
@@ -161,19 +155,19 @@ export default function App({ footer }) {
}
<section id="content" ref={contentRef}>
<Routes>
- <Route exact path="/" element={<Discussions visitor={visitor} />} />
- <Route exact path="/home" element={<Home visitor={visitor} />} />
- <Route exact path="/discover" element={<Discover visitor={visitor} />} />
- <Route exact path="/settings" element={<Settings visitor={visitor} onChange={auth} />} />
- <Route exact path="/login" element={<Login visitor={visitor} onAuth={auth} />} />
- <Route exact path="/post" element={<Post visitor={visitor} />} />
- <Route exact path="/pm" element={<Contacts visitor={visitor} />} />
- <Route exact path="/pm/:user" element={<Chat connection={eventSource} visitor={visitor} />} />
+ <Route exact path="/" element={<Discussions />} />
+ <Route exact path="/home" element={<Home />} />
+ <Route exact path="/discover" element={<Discover />} />
+ <Route exact path="/settings" element={<Settings onChange={auth} />} />
+ <Route exact path="/login" element={<Login onAuth={auth} />} />
+ <Route exact path="/post" element={<Post />} />
+ <Route exact path="/pm" element={<Contacts />} />
+ <Route exact path="/pm/:user" element={<Chat connection={eventSource} />} />
<Route exact path="/:user/friends" element={<Friends />} />
<Route exact path="/:user/readers" element={<Readers />} />
- <Route exact path="/:user" element={<Blog visitor={visitor} />} />
- <Route exact path="/tag/:tag" element={<Tag visitor={visitor} />} />
- <Route exact path="/:user/:mid" element={<Thread connection={eventSource} visitor={visitor} />} />
+ <Route exact path="/:user" element={<Blog />} />
+ <Route exact path="/tag/:tag" element={<Tag />} />
+ <Route exact path="/:user/:mid" element={<Thread connection={eventSource} />} />
</Routes>
</section>
</div>