fix bugs in RoomSubListHeader splitout

This commit is contained in:
Matthew Hodgson 2017-04-18 02:43:06 +01:00
parent 5ff49f4000
commit f8aa2c3487
2 changed files with 22 additions and 9 deletions

View File

@ -28,6 +28,7 @@ var RoomNotifs = require('matrix-react-sdk/lib/RoomNotifs');
var FormattingUtils = require('matrix-react-sdk/lib/utils/FormattingUtils'); var FormattingUtils = require('matrix-react-sdk/lib/utils/FormattingUtils');
var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton'); var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton');
var ConstantTimeDispatcher = require('matrix-react-sdk/lib/ConstantTimeDispatcher'); var ConstantTimeDispatcher = require('matrix-react-sdk/lib/ConstantTimeDispatcher');
var RoomSubListHeader = require('./RoomSubListHeader.js');
// turn this on for drag & drop console debugging galore // turn this on for drag & drop console debugging galore
var debug = false; var debug = false;
@ -104,7 +105,7 @@ var RoomSubList = React.createClass({
componentWillMount: function() { componentWillMount: function() {
constantTimeDispatcher.register("RoomSubList.sort", this.props.tagName, this.onSort); constantTimeDispatcher.register("RoomSubList.sort", this.props.tagName, this.onSort);
this.sortList(this.applySearchFilter(this.props.list, this.props.searchFilter), this.props.order); this.sortList(this.applySearchFilter(this.props.list, this.props.searchFilter), this.props.order);
this._fixUndefinedOrder(list); this._fixUndefinedOrder(this.props.list);
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
@ -115,7 +116,7 @@ var RoomSubList = React.createClass({
// order the room list appropriately before we re-render // order the room list appropriately before we re-render
//if (debug) console.log("received new props, list = " + newProps.list); //if (debug) console.log("received new props, list = " + newProps.list);
this.sortList(this.applySearchFilter(newProps.list, newProps.searchFilter), newProps.order); this.sortList(this.applySearchFilter(newProps.list, newProps.searchFilter), newProps.order);
this._fixUndefinedOrder(list); this._fixUndefinedOrder(newProps.list);
}, },
onSort: function() { onSort: function() {
@ -133,7 +134,7 @@ var RoomSubList = React.createClass({
// The header is collapsable if it is hidden or not stuck // The header is collapsable if it is hidden or not stuck
// The dataset elements are added in the RoomList _initAndPositionStickyHeaders method // The dataset elements are added in the RoomList _initAndPositionStickyHeaders method
isCollapsableOnClick: function() { isCollapsableOnClick: function() {
var stuck = this.refs.header.dataset.stuck; var stuck = this.refs.header.refs.header.dataset.stuck;
if (this.state.hidden || stuck === undefined || stuck === "none") { if (this.state.hidden || stuck === undefined || stuck === "none") {
return true; return true;
} else { } else {
@ -156,7 +157,7 @@ var RoomSubList = React.createClass({
this.props.onHeaderClick(isHidden); this.props.onHeaderClick(isHidden);
} else { } else {
// The header is stuck, so the click is to be interpreted as a scroll to the header // The header is stuck, so the click is to be interpreted as a scroll to the header
this.props.onHeaderClick(this.state.hidden, this.refs.header.dataset.originalPosition); this.props.onHeaderClick(this.state.hidden, this.refs.header.refs.header.dataset.originalPosition);
} }
}, },
@ -508,12 +509,15 @@ var RoomSubList = React.createClass({
return connectDropTarget( return connectDropTarget(
<div> <div>
<RoomSubListHeader <RoomSubListHeader
ref='header'
label={ this.props.label } label={ this.props.label }
tagName={ this.props.tagName } tagName={ this.props.tagName }
roomCount={ roomCount } roomCount={ roomCount }
collapsed={ this.props.collapsed } collapsed={ this.props.collapsed }
hidden={ this.state.hidden } hidden={ this.state.hidden }
isIncomingCallRoom={ isIncomingCallRoom } isIncomingCallRoom={ isIncomingCallRoom }
roomNotificationCount={ this.roomNotificationCount() }
onClick={ this.onClick }
onHeaderClick={ this.props.onHeaderClick } onHeaderClick={ this.props.onHeaderClick }
/> />
{ subList } { subList }
@ -526,12 +530,15 @@ var RoomSubList = React.createClass({
<div className="mx_RoomSubList"> <div className="mx_RoomSubList">
{ this.props.alwaysShowHeader ? { this.props.alwaysShowHeader ?
<RoomSubListHeader <RoomSubListHeader
ref='header'
label={ this.props.label } label={ this.props.label }
tagName={ this.props.tagName } tagName={ this.props.tagName }
roomCount={ roomCount } roomCount={ roomCount }
collapsed={ this.props.collapsed } collapsed={ this.props.collapsed }
hidden={ this.state.hidden } hidden={ this.state.hidden }
isIncomingCallRoom={ isIncomingCallRoom } isIncomingCallRoom={ isIncomingCallRoom }
roomNotificationCount={ this.roomNotificationCount() }
onClick={ this.onClick }
onHeaderClick={ this.props.onHeaderClick } onHeaderClick={ this.props.onHeaderClick }
/> />
: undefined } : undefined }

View File

@ -20,8 +20,7 @@ var React = require('react');
var ReactDOM = require('react-dom'); var ReactDOM = require('react-dom');
var classNames = require('classnames'); var classNames = require('classnames');
var sdk = require('matrix-react-sdk') var sdk = require('matrix-react-sdk')
var dis = require('matrix-react-sdk/lib/dispatcher'); var FormattingUtils = require('matrix-react-sdk/lib/utils/FormattingUtils');
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var RoomNotifs = require('matrix-react-sdk/lib/RoomNotifs'); var RoomNotifs = require('matrix-react-sdk/lib/RoomNotifs');
var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton'); var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton');
var ConstantTimeDispatcher = require('matrix-react-sdk/lib/ConstantTimeDispatcher'); var ConstantTimeDispatcher = require('matrix-react-sdk/lib/ConstantTimeDispatcher');
@ -32,10 +31,15 @@ module.exports = React.createClass({
propTypes: { propTypes: {
label: React.PropTypes.string.isRequired, label: React.PropTypes.string.isRequired,
tagName: React.PropTypes.string, tagName: React.PropTypes.string,
roomCount: React.PropTypes.string, roomCount: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]),
collapsed: React.PropTypes.bool.isRequired, // is LeftPanel collapsed? collapsed: React.PropTypes.bool.isRequired, // is LeftPanel collapsed?
isIncomingCallRoom: React.PropTypes.bool, isIncomingCallRoom: React.PropTypes.bool,
roomNotificationCount: React.PropTypes.array,
hidden: React.PropTypes.bool, hidden: React.PropTypes.bool,
onClick: React.PropTypes.func,
onHeaderClick: React.PropTypes.func, onHeaderClick: React.PropTypes.func,
}, },
@ -60,7 +64,7 @@ module.exports = React.createClass({
render: function() { render: function() {
var TintableSvg = sdk.getComponent("elements.TintableSvg"); var TintableSvg = sdk.getComponent("elements.TintableSvg");
var subListNotifications = this.roomNotificationCount(); var subListNotifications = this.props.roomNotificationCount;
var subListNotifCount = subListNotifications[0]; var subListNotifCount = subListNotifications[0];
var subListNotifHighlight = subListNotifications[1]; var subListNotifHighlight = subListNotifications[1];
@ -86,6 +90,7 @@ module.exports = React.createClass({
// When collapsed, allow a long hover on the header to show user // When collapsed, allow a long hover on the header to show user
// the full tag name and room count // the full tag name and room count
var title; var title;
var roomCount = this.props.roomCount;
if (this.props.collapsed) { if (this.props.collapsed) {
title = this.props.label; title = this.props.label;
if (roomCount !== '') { if (roomCount !== '') {
@ -93,6 +98,7 @@ module.exports = React.createClass({
} }
} }
var incomingCall;
if (this.props.isIncomingCallRoom) { if (this.props.isIncomingCallRoom) {
var IncomingCallBox = sdk.getComponent("voip.IncomingCallBox"); var IncomingCallBox = sdk.getComponent("voip.IncomingCallBox");
incomingCall = <IncomingCallBox className="mx_RoomSubList_incomingCall" incomingCall={ this.props.incomingCall }/>; incomingCall = <IncomingCallBox className="mx_RoomSubList_incomingCall" incomingCall={ this.props.incomingCall }/>;
@ -102,7 +108,7 @@ module.exports = React.createClass({
return ( return (
<div className="mx_RoomSubList_labelContainer" title={ title } ref="header"> <div className="mx_RoomSubList_labelContainer" title={ title } ref="header">
<AccessibleButton onClick={ this.onClick } className="mx_RoomSubList_label" tabIndex={tabindex}> <AccessibleButton onClick={ this.props.onClick } className="mx_RoomSubList_label" tabIndex={tabindex}>
{ this.props.collapsed ? '' : this.props.label } { this.props.collapsed ? '' : this.props.label }
<div className="mx_RoomSubList_roomCount">{ roomCount }</div> <div className="mx_RoomSubList_roomCount">{ roomCount }</div>
<div className={chevronClasses}></div> <div className={chevronClasses}></div>