Fix discussions user page (#2225)

* Fixed up discussions user page, improve discussion list state signature
This commit is contained in:
Alexander Skvortsov 2020-07-03 01:16:08 -04:00 committed by GitHub
parent 90dd8f60a5
commit 56b6e85255
3 changed files with 16 additions and 13 deletions

View File

@ -84,7 +84,7 @@ export default class ForumApplication extends Application {
*
* @type {DiscussionListState}
*/
this.discussions = new DiscussionListState({ forumApp: this });
this.discussions = new DiscussionListState({}, this);
/**
* @deprecated beta 14, remove in beta 15.

View File

@ -1,5 +1,6 @@
import UserPage from './UserPage';
import DiscussionList from './DiscussionList';
import DiscussionListState from '../states/DiscussionListState';
/**
* The `DiscussionsUserPage` component shows a discussion list inside of a user
@ -12,16 +13,18 @@ export default class DiscussionsUserPage extends UserPage {
this.loadUser(m.route.param('username'));
}
content() {
return (
<div className="DiscussionsUserPage">
{DiscussionList.component({
params: {
q: 'author:' + this.user.username(),
show(user) {
super.show(user);
this.state = new DiscussionListState({
q: 'author:' + user.username(),
sort: 'newest',
},
})}
</div>
);
});
this.state.refresh();
}
content() {
return <div className="DiscussionsUserPage">{DiscussionList.component({ state: this.state })}</div>;
}
}

View File

@ -1,8 +1,8 @@
export default class DiscussionListState {
constructor({ params = {}, forumApp = app } = {}) {
constructor(params = {}, app = window.app) {
this.params = params;
this.app = forumApp;
this.app = app;
this.discussions = [];