1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 23:47:32 +02:00

DiscussionListPane: Inject state, extract method

This commit is contained in:
Franz Liedke
2020-09-11 18:39:23 +02:00
parent aeaa9a4b73
commit 383a7e559f
2 changed files with 21 additions and 3 deletions

View File

@@ -5,13 +5,22 @@ const hotEdge = (e) => {
if (e.pageX < 10) app.pane.show();
};
/**
* The `DiscussionListPane` component displays the list of previously viewed
* discussions in a panel that can be displayed by moving the mouse to the left
* edge of the screen, where it can also be pinned in place.
*
* ### Props
*
* - `state` A DiscussionListState object that represents the discussion lists's state.
*/
export default class DiscussionListPane extends Component {
view() {
if (!app.discussions.hasDiscussions()) {
if (!this.attrs.state.hasDiscussions()) {
return;
}
return <div className="DiscussionPage-list">{!$('.App-navigation').is(':visible') && <DiscussionList state={app.discussions} />}</div>;
return <div className="DiscussionPage-list">{this.enoughSpace() && <DiscussionList state={this.attrs.state} />}</div>;
}
oncreate(vnode) {
@@ -46,4 +55,13 @@ export default class DiscussionListPane extends Component {
onremove() {
$(document).off('mousemove', hotEdge);
}
/**
* Are we on a device that's larger than we consider "mobile"?
*
* @returns {boolean}
*/
enoughSpace() {
return !$('.App-navigation').is(':visible');
}
}

View File

@@ -70,7 +70,7 @@ export default class DiscussionPage extends Page {
return (
<div className="DiscussionPage">
<DiscussionListPane />
<DiscussionListPane state={app.discussions} />
<div className="DiscussionPage-discussion">
{discussion
? [