modularize and invert logic, so banned etc will count as left

This commit is contained in:
Michael Telatynski 2017-08-28 00:46:28 +01:00
parent 433cd505ee
commit 21af3fe189
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E

View file

@ -40,6 +40,8 @@ import withMatrixClient from '../../../wrappers/withMatrixClient';
import AccessibleButton from '../elements/AccessibleButton'; import AccessibleButton from '../elements/AccessibleButton';
import GeminiScrollbar from 'react-gemini-scrollbar'; import GeminiScrollbar from 'react-gemini-scrollbar';
// States which both sides of the dmRoom must have for it to be considered relevant.
const joinStates = ['invite', 'join'];
module.exports = withMatrixClient(React.createClass({ module.exports = withMatrixClient(React.createClass({
displayName: 'MemberInfo', displayName: 'MemberInfo',
@ -620,11 +622,11 @@ module.exports = withMatrixClient(React.createClass({
const room = this.props.matrixClient.getRoom(roomId); const room = this.props.matrixClient.getRoom(roomId);
if (room) { if (room) {
const me = room.getMember(this.props.matrixClient.credentials.userId); const me = room.getMember(this.props.matrixClient.credentials.userId);
// not a DM room if we have left it // not a DM room if we have are not joined/invited
if (!me.membership || me.membership === 'leave') continue; if (!me.membership || !joinStates.includes(me.membership)) continue;
// not a DM room if they have left it // not a DM room if they are not joined/invited
const them = this.props.member; const them = this.props.member;
if (!them.membership || them.membership === 'leave') continue; if (!them.membership || !joinStates.includes(them.membership)) continue;
const highlight = room.getUnreadNotificationCount('highlight') > 0 || me.membership === 'invite'; const highlight = room.getUnreadNotificationCount('highlight') > 0 || me.membership === 'invite';