mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Avoid NPEs by using ref method for collecting loggedInView in MatrixChat
This commit is contained in:
parent
9975941f3c
commit
8b11b10531
@ -1065,10 +1065,10 @@ export default React.createClass({
|
|||||||
// this if we are not scrolled up in the view. To find out, delegate to
|
// this if we are not scrolled up in the view. To find out, delegate to
|
||||||
// the timeline panel. If the timeline panel doesn't exist, then we assume
|
// the timeline panel. If the timeline panel doesn't exist, then we assume
|
||||||
// it is safe to reset the timeline.
|
// it is safe to reset the timeline.
|
||||||
if (!self.refs.loggedInView) {
|
if (!self._loggedInView) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return self.refs.loggedInView.canResetTimelineInRoom(roomId);
|
return self._loggedInView.canResetTimelineInRoom(roomId);
|
||||||
});
|
});
|
||||||
|
|
||||||
cli.on('sync', function(state, prevState) {
|
cli.on('sync', function(state, prevState) {
|
||||||
@ -1487,6 +1487,10 @@ export default React.createClass({
|
|||||||
return this.props.makeRegistrationUrl(params);
|
return this.props.makeRegistrationUrl(params);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_collectLoggedInView: function(ref) {
|
||||||
|
this._loggedInView = ref;
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
// console.log(`Rendering MatrixChat with view ${this.state.view}`);
|
// console.log(`Rendering MatrixChat with view ${this.state.view}`);
|
||||||
|
|
||||||
@ -1519,7 +1523,7 @@ export default React.createClass({
|
|||||||
*/
|
*/
|
||||||
const LoggedInView = sdk.getComponent('structures.LoggedInView');
|
const LoggedInView = sdk.getComponent('structures.LoggedInView');
|
||||||
return (
|
return (
|
||||||
<LoggedInView ref="loggedInView" matrixClient={MatrixClientPeg.get()}
|
<LoggedInView ref={this._collectLoggedInView} matrixClient={MatrixClientPeg.get()}
|
||||||
onRoomCreated={this.onRoomCreated}
|
onRoomCreated={this.onRoomCreated}
|
||||||
onUserSettingsClose={this.onUserSettingsClose}
|
onUserSettingsClose={this.onUserSettingsClose}
|
||||||
onRegistered={this.onRegistered}
|
onRegistered={this.onRegistered}
|
||||||
|
Loading…
Reference in New Issue
Block a user