mirror of
https://github.com/flarum/core.git
synced 2025-08-05 07:57:46 +02:00
DiscussionListPane: Inject state, extract method
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@ export default class DiscussionPage extends Page {
|
||||
|
||||
return (
|
||||
<div className="DiscussionPage">
|
||||
<DiscussionListPane />
|
||||
<DiscussionListPane state={app.discussions} />
|
||||
<div className="DiscussionPage-discussion">
|
||||
{discussion
|
||||
? [
|
||||
|
Reference in New Issue
Block a user