ForceUpdate the scrollpanel when the aux panel changes size

Catch some more cases when we ought to be updating the gemini scroll stuff.
This commit is contained in:
Richard van der Hoff 2016-03-08 12:16:34 +00:00
parent 393e8ff612
commit 6c928f12b2
3 changed files with 38 additions and 19 deletions

View file

@ -991,10 +991,10 @@ module.exports = React.createClass({
// but it's better than the video going missing entirely // but it's better than the video going missing entirely
if (auxPanelMaxHeight < 50) auxPanelMaxHeight = 50; if (auxPanelMaxHeight < 50) auxPanelMaxHeight = 50;
// we may need to resize the gemini panel after changing the aux panel this.setState({auxPanelMaxHeight: auxPanelMaxHeight});
// size, so add a callback to onChildResize.
this.setState({auxPanelMaxHeight: auxPanelMaxHeight}, // changing the maxHeight on the auxpanel will trigger a callback go
this.onChildResize); // onChildResize, so no need to worry about that here.
}, },
onFullscreenClick: function() { onFullscreenClick: function() {
@ -1042,8 +1042,15 @@ module.exports = React.createClass({
// XXX: this is a bit naughty; we should be doing this via props // XXX: this is a bit naughty; we should be doing this via props
if (show) { if (show) {
this.setState({editingRoomSettings: true}); this.setState({editingRoomSettings: true});
var self = this; }
setTimeout(function() { self.onResize() }, 0); },
// this has to be a proper method rather than an unnamed function,
// otherwise react calls it with null on each update.
_gatherTimelinePanelRef: function(r) {
this.refs.messagePanel = r;
if(r) {
this.updateTint();
} }
}, },
@ -1206,7 +1213,7 @@ module.exports = React.createClass({
draggingFile={this.state.draggingFile} draggingFile={this.state.draggingFile}
displayConfCallNotification={this.state.displayConfCallNotification} displayConfCallNotification={this.state.displayConfCallNotification}
maxHeight={this.state.auxPanelMaxHeight} maxHeight={this.state.auxPanelMaxHeight}
onCallViewVideoRezize={this.onChildResize} > onResize={this.onChildResize} >
{ aux } { aux }
</AuxPanel> </AuxPanel>
); );
@ -1285,12 +1292,7 @@ module.exports = React.createClass({
} }
var messagePanel = ( var messagePanel = (
<TimelinePanel ref={(r) => { <TimelinePanel ref={this._gatherTimelinePanelRef}
this.refs.messagePanel = r;
if(r) {
this.updateTint();
}
}}
room={this.state.room} room={this.state.room}
hidden={hideMessagePanel} hidden={hideMessagePanel}
highlightedEventId={this.props.highlightedEventId} highlightedEventId={this.props.highlightedEventId}

View file

@ -18,6 +18,7 @@ var React = require('react');
var MatrixClientPeg = require("../../../MatrixClientPeg"); var MatrixClientPeg = require("../../../MatrixClientPeg");
var sdk = require('../../../index'); var sdk = require('../../../index');
var dis = require("../../../dispatcher"); var dis = require("../../../dispatcher");
var ObjectUtils = require('../../../ObjectUtils');
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'AuxPanel', displayName: 'AuxPanel',
@ -39,9 +40,21 @@ module.exports = React.createClass({
// therein // therein
maxHeight: React.PropTypes.number, maxHeight: React.PropTypes.number,
// a callback which is called when the video element in a voip call is // a callback which is called when the content of the aux panel changes
// resized due to a change in video metadata // content in a way that is likely to make it change size.
onCallViewVideoResize: React.PropTypes.func, onResize: React.PropTypes.func,
},
shouldComponentUpdate: function(nextProps, nextState) {
return (!ObjectUtils.shallowEqual(this.props, nextProps) ||
!ObjectUtils.shallowEqual(this.state, nextState));
},
componentDidUpdate: function(prevProps, prevState) {
// most changes are likely to cause a resize
if (this.props.onResize) {
this.props.onResize();
}
}, },
onConferenceNotificationClick: function() { onConferenceNotificationClick: function() {
@ -87,7 +100,7 @@ module.exports = React.createClass({
var callView = ( var callView = (
<CallView ref="callView" room={this.props.room} <CallView ref="callView" room={this.props.room}
ConferenceHandler={this.props.conferenceHandler} ConferenceHandler={this.props.conferenceHandler}
onResize={this.props.onCallViewVideoResize} onResize={this.props.onResize}
maxVideoHeight={this.props.maxHeight} maxVideoHeight={this.props.maxHeight}
/> />
); );

View file

@ -38,8 +38,8 @@ module.exports = React.createClass({
// a callback which is called when the user clicks on the video div // a callback which is called when the user clicks on the video div
onClick: React.PropTypes.func, onClick: React.PropTypes.func,
// a callback which is called when the video within the callview is // a callback which is called when the content in the callview changes
// resized due to a change in video metadata // in a way that is likely to cause a resize.
onResize: React.PropTypes.func, onResize: React.PropTypes.func,
}, },
@ -96,6 +96,10 @@ module.exports = React.createClass({
this.getVideoView().getRemoteVideoElement().style.display = "none"; this.getVideoView().getRemoteVideoElement().style.display = "none";
dis.dispatch({action: 'video_fullscreen', fullscreen: false}); dis.dispatch({action: 'video_fullscreen', fullscreen: false});
} }
if (this.props.onResize) {
this.props.onResize();
}
}, },
getVideoView: function() { getVideoView: function() {