-
-
Notifications
You must be signed in to change notification settings - Fork 827
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of niggles
@@ -101,6 +108,7 @@ module.exports = React.createClass({ | |||
middleOpacity: 1.0, | |||
}); | |||
dis.unregister(this.dispatcherRef); | |||
MatrixClientPeg.get().removeListener("RoomMember.membership", this._onInviteStateChange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might have been logged out by the time we get here; needs a null check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean MatrixClientPeg.get()
is nullable?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ grep -rn "MatrixClientPeg\.get()\." matrix-react-sdk/src/ | wc -l
264
There are a lot of assumptions in other UI components that assume MatrixClientPeg
is not null
. These are generally safe assumptions because the UI component in question isn't shown when the user is not logged in: as is the case here. I would rather not increase the SNR any more than I need to. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, MatrixClientPeg.get()
will return null after you log out.
In general you are right, but this is in an componentWillUnmount
method which will be called when the user logs out. You should find that any other references to MatrixClientPeg.get
in componentWillUnmount
have null guards - any which don't are also bugs.
(We're actually in the process of switching to passing the MatrixClient via the react context rather than using the MatrixClientPeg singleton, which means that components can rely on the MatrixClient not changing under them. But we're already using MatrixClientPeg in this component and I'd rather not mix usage in a single component.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh okay. Done.
this.setState({ | ||
rejectingInvites: false | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needs a .done()
to catch exceptions from the setState?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, yes you're right.
/me pines for bluebird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
PTAL @richvdh |
No description provided.