forum: add DiscussionsUserPage component

This commit is contained in:
David Sevilla Martin 2020-02-07 09:35:44 -05:00
parent 80d8707d15
commit 2a66dc5572
No known key found for this signature in database
GPG Key ID: F764F1417E16B15F
2 changed files with 29 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import IndexPage from './components/IndexPage';
import DiscussionList from './components/DiscussionList';
import DiscussionPage from './components/DiscussionPage';
import PostsUserPage from './components/PostsUserPage';
import DiscussionsUserPage from './components/DiscussionsUserPage';
import SettingsPage from './components/SettingsPage';
import CommentPost from './components/CommentPost';
@ -26,7 +27,7 @@ export default class Forum extends Application {
user: { path: '/u/:username', component: PostsUserPage },
'user.posts': { path: '/u/:username', component: PostsUserPage },
'user.discussions': { path: '/u/:username/discussions', component: PostsUserPage },
'user.discussions': { path: '/u/:username/discussions', component: DiscussionsUserPage },
settings: { path: '/settings', component: SettingsPage },

View File

@ -0,0 +1,27 @@
import UserPage from './UserPage';
import DiscussionList from './DiscussionList';
/**
* The `DiscussionsUserPage` component shows a discussion list inside of a user
* page.
*/
export default class DiscussionsUserPage extends UserPage {
oninit(vnode) {
super.oninit(vnode);
this.loadUser(m.route.param('username'));
}
content() {
return (
<div className="DiscussionsUserPage">
{DiscussionList.component({
params: {
q: `author:${this.user.username()}`,
sort: 'newest',
},
})}
</div>
);
}
}