From 869c08a790e62ddb3f11189bc7eae8f658487688 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 18 Dec 2015 11:56:22 +0000 Subject: [PATCH] Add onHeaderClick and alwaysShowHeader props to RoomSubList for archived room clicking --- src/components/structures/RoomSubList.js | 30 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/components/structures/RoomSubList.js b/src/components/structures/RoomSubList.js index f7efb4254f..f6f10ec6fd 100644 --- a/src/components/structures/RoomSubList.js +++ b/src/components/structures/RoomSubList.js @@ -64,7 +64,9 @@ var RoomSubList = React.createClass({ bottommost: React.PropTypes.bool, selectedRoom: React.PropTypes.string.isRequired, activityMap: React.PropTypes.object.isRequired, - collapsed: React.PropTypes.bool.isRequired + collapsed: React.PropTypes.bool.isRequired, + onHeaderClick: React.PropTypes.func, + alwaysShowHeader: React.PropTypes.bool }, getInitialState: function() { @@ -74,6 +76,12 @@ var RoomSubList = React.createClass({ }; }, + getDefaultProps: function() { + return { + onHeaderClick: function() {} // NOP + }; + }, + componentWillMount: function() { this.sortList(this.props.list, this.props.order); }, @@ -85,7 +93,9 @@ var RoomSubList = React.createClass({ }, onClick: function(ev) { - this.setState({ hidden : !this.state.hidden }); + var isHidden = !this.state.hidden; + this.setState({ hidden : isHidden }); + this.props.onHeaderClick(isHidden); }, tsOfNewestEvent: function(room) { @@ -244,6 +254,17 @@ var RoomSubList = React.createClass({ }); }, + _getHeaderJsx: function() { + return ( +

+ { this.props.collapsed ? '' : this.props.label } + +

+ ); + }, + render: function() { var connectDropTarget = this.props.connectDropTarget; var RoomDropTarget = sdk.getComponent('rooms.RoomDropTarget'); @@ -275,9 +296,7 @@ var RoomSubList = React.createClass({ return connectDropTarget(
-

{ this.props.collapsed ? '' : this.props.label } - -

+ { this._getHeaderJsx() } { subList }
); @@ -285,6 +304,7 @@ var RoomSubList = React.createClass({ else { return (
+ { this.props.alwaysShowHeader ? this._getHeaderJsx() : undefined }
); }