aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Feeds.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/ui/Feeds.js')
-rw-r--r--vnext/src/ui/Feeds.js31
1 files changed, 16 insertions, 15 deletions
diff --git a/vnext/src/ui/Feeds.js b/vnext/src/ui/Feeds.js
index 84319c28..75f1800d 100644
--- a/vnext/src/ui/Feeds.js
+++ b/vnext/src/ui/Feeds.js
@@ -10,6 +10,7 @@ import Spinner from './Spinner';
import UserInfo from './UserInfo';
import { getMessages } from '../api';
+import { useVisitor } from './VisitorContext';
/**
* @typedef {object} Query
@@ -21,12 +22,12 @@ import { getMessages } from '../api';
/**
* @typedef {object} PageProps
* @property {string=} search
- * @property {import('../api').SecureUser} visitor
* @property {import('../api').Message[]=} msgs
*/
-function RequireAuth({ visitor, children }) {
+function RequireAuth({ children }) {
let location = useLocation();
+ let [ visitor ] = useVisitor();
if (!visitor.hash) {
// Redirect them to the /login page, but save the current location they were
// trying to go to when they were redirected. This allows us to send them
@@ -41,7 +42,7 @@ function RequireAuth({ visitor, children }) {
/**
* @param {PageProps} props
*/
-export function Discover({ visitor }) {
+export function Discover() {
const location = useLocation();
let search = qs.parse(location.search.substring(1));
const query = {
@@ -49,24 +50,24 @@ export function Discover({ visitor }) {
search: search,
pageParam: search.search ? 'page' : 'before_mid'
};
- return (<Feed query={query} visitor={visitor} />);
+ return (<Feed query={query} />);
}
/**
* @param {PageProps} props
*/
-export function Discussions({ visitor }) {
+export function Discussions() {
const query = {
baseUrl: '/api/messages/discussions',
pageParam: 'to'
};
- return (<Feed query={query} visitor={visitor} />);
+ return (<Feed query={query} />);
}
/**
* @param {PageProps} props
*/
-export function Blog({ visitor }) {
+export function Blog() {
const { user } = useParams();
const location = useLocation();
const search = {
@@ -83,7 +84,7 @@ export function Blog({ visitor }) {
<div className="msg-cont">
<UserInfo uname={user} />
</div>
- <Feed query={query} visitor={visitor} />
+ <Feed query={query} />
</>
);
}
@@ -91,7 +92,7 @@ export function Blog({ visitor }) {
/**
* @param {PageProps} props
*/
-export function Tag({ visitor }) {
+export function Tag() {
const params = useParams();
const { tag } = params;
const query = {
@@ -101,27 +102,26 @@ export function Tag({ visitor }) {
},
pageParam: 'before_mid'
};
- return (<Feed query={query} visitor={visitor} />);
+ return (<Feed query={query} />);
}
/**
* @param {PageProps} props
*/
-export function Home({ visitor }) {
+export function Home() {
const query = {
baseUrl: '/api/home',
pageParam: 'before_mid'
};
return (
- <RequireAuth visitor={visitor}>
- <Feed query={query} visitor={visitor} />
+ <RequireAuth>
+ <Feed query={query} />
</RequireAuth>
);
}
/**
* @typedef {object} FeedState
- * @property { import('../api').SecureUser } visitor
* @property { import('../api').Message[]= } msgs
* @property { Query} query
*/
@@ -129,8 +129,9 @@ export function Home({ visitor }) {
/**
* @param {FeedState} props
*/
-function Feed({ visitor, query }) {
+function Feed({ query }) {
const location = useLocation();
+ const [visitor] = useVisitor();
const [state, setState] = useState({
hash: visitor.hash,
msgs: [],