Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1665 from matrix-org/luke/fix-matrix-chat-logged-…
Browse files Browse the repository at this point in the history
…in-view-ref

Avoid NPEs by using ref method for collecting loggedInView in MatrixChat
  • Loading branch information
lukebarnard1 authored Dec 15, 2017
2 parents 9975941 + 8b11b10 commit 0a944e0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,10 @@ export default React.createClass({
// 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
// it is safe to reset the timeline.
if (!self.refs.loggedInView) {
if (!self._loggedInView) {
return true;
}
return self.refs.loggedInView.canResetTimelineInRoom(roomId);
return self._loggedInView.canResetTimelineInRoom(roomId);
});

cli.on('sync', function(state, prevState) {
Expand Down Expand Up @@ -1487,6 +1487,10 @@ export default React.createClass({
return this.props.makeRegistrationUrl(params);
},

_collectLoggedInView: function(ref) {
this._loggedInView = ref;
},

render: function() {
// console.log(`Rendering MatrixChat with view ${this.state.view}`);

Expand Down Expand Up @@ -1519,7 +1523,7 @@ export default React.createClass({
*/
const LoggedInView = sdk.getComponent('structures.LoggedInView');
return (
<LoggedInView ref="loggedInView" matrixClient={MatrixClientPeg.get()}
<LoggedInView ref={this._collectLoggedInView} matrixClient={MatrixClientPeg.get()}
onRoomCreated={this.onRoomCreated}
onUserSettingsClose={this.onUserSettingsClose}
onRegistered={this.onRegistered}
Expand Down

0 comments on commit 0a944e0

Please sign in to comment.