diff --git a/src/components/views/rooms/EntityTile.js b/src/components/views/rooms/EntityTile.js index 949eebada0..6b3264d123 100644 --- a/src/components/views/rooms/EntityTile.js +++ b/src/components/views/rooms/EntityTile.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -32,7 +33,11 @@ const PRESENCE_CLASS = { }; -function presenceClassForMember(presenceState, lastActiveAgo) { +function presenceClassForMember(presenceState, lastActiveAgo, showPresence) { + if (showPresence === false) { + return 'mx_EntityTile_online_beenactive'; + } + // offline is split into two categories depending on whether we have // a last_active_ago for them. if (presenceState == 'offline') { @@ -64,6 +69,7 @@ const EntityTile = React.createClass({ shouldComponentUpdate: PropTypes.func, onClick: PropTypes.func, suppressOnHover: PropTypes.bool, + showPresence: PropTypes.bool, }, getDefaultProps: function() { @@ -75,6 +81,7 @@ const EntityTile = React.createClass({ presenceLastTs: 0, showInviteButton: false, suppressOnHover: false, + showPresence: true, }; }, @@ -99,7 +106,7 @@ const EntityTile = React.createClass({ render: function() { const presenceClass = presenceClassForMember( - this.props.presenceState, this.props.presenceLastActiveAgo, + this.props.presenceState, this.props.presenceLastActiveAgo, this.props.showPresence, ); let mainClassName = "mx_EntityTile "; @@ -114,15 +121,21 @@ const EntityTile = React.createClass({ mainClassName += " mx_EntityTile_hover"; const PresenceLabel = sdk.getComponent("rooms.PresenceLabel"); + let presenceLabel = null; + let nameClasses = 'mx_EntityTile_name'; + if (this.props.showPresence) { + presenceLabel = ; + nameClasses += ' mx_EntityTile_name_hover'; + } nameEl = (
- + { name } - + {presenceLabel}
); } else { diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 19afe8e388..dd260933be 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -1,6 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd -Copyright 2017 Vector Creations Ltd +Copyright 2017, 2018 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import withMatrixClient from '../../../wrappers/withMatrixClient'; import AccessibleButton from '../elements/AccessibleButton'; import GeminiScrollbar from 'react-gemini-scrollbar'; import RoomViewStore from '../../../stores/RoomViewStore'; +import SdkConfig from '../../../SdkConfig'; module.exports = withMatrixClient(React.createClass({ displayName: 'MemberInfo', @@ -861,6 +862,20 @@ module.exports = withMatrixClient(React.createClass({ const powerLevelEvent = room ? room.currentState.getStateEvents("m.room.power_levels", "") : null; const powerLevelUsersDefault = powerLevelEvent ? powerLevelEvent.getContent().users_default : 0; + const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"]; + const hsUrl = this.props.matrixClient.baseUrl; + let showPresence = true; + if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) { + showPresence = enablePresenceByHsUrl[hsUrl]; + } + + let presenceLabel = null; + if (showPresence) { + presenceLabel = ; + } + let roomMemberDetails = null; if (this.props.member.roomId) { // is in room const PowerSelector = sdk.getComponent('elements.PowerSelector'); @@ -877,9 +892,7 @@ module.exports = withMatrixClient(React.createClass({
- + {presenceLabel}
; } diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 1c5eba7fbc..620cfe33fc 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -1,7 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd -Copyright 2017 New Vector Ltd +Copyright 2017, 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ limitations under the License. import React from 'react'; import { _t } from '../../../languageHandler'; +import SdkConfig from '../../../SdkConfig'; const MatrixClientPeg = require("../../../MatrixClientPeg"); const sdk = require('../../../index'); const GeminiScrollbar = require('react-gemini-scrollbar'); @@ -59,6 +60,14 @@ module.exports = React.createClass({ // the information contained in presence events). cli.on("User.lastPresenceTs", this.onUserLastPresenceTs); // cli.on("Room.timeline", this.onRoomTimeline); + + const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"]; + const hsUrl = MatrixClientPeg.get().baseUrl; + + this._showPresence = true; + if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) { + this._showPresence = enablePresenceByHsUrl[hsUrl]; + } }, componentWillUnmount: function() { @@ -345,7 +354,7 @@ module.exports = React.createClass({ const memberList = members.map((userId) => { const m = this.memberDict[userId]; return ( - + ); }); @@ -358,7 +367,10 @@ module.exports = React.createClass({ if (membership === "invite") { const EntityTile = sdk.getComponent("rooms.EntityTile"); memberList.push(...this._getPending3PidInvites().map((e) => { - return ; + return ; })); } diff --git a/src/components/views/rooms/MemberTile.js b/src/components/views/rooms/MemberTile.js index 50ee6befa8..2359bc242c 100644 --- a/src/components/views/rooms/MemberTile.js +++ b/src/components/views/rooms/MemberTile.js @@ -30,6 +30,13 @@ module.exports = React.createClass({ propTypes: { member: PropTypes.any.isRequired, // RoomMember + showPresence: PropTypes.bool, + }, + + getDefaultProps: function() { + return { + showPresence: true, + }; }, getInitialState: function() { @@ -99,7 +106,7 @@ module.exports = React.createClass({ presenceLastTs={member.user ? member.user.lastPresenceTs : 0} presenceCurrentlyActive={member.user ? member.user.currentlyActive : false} avatarJsx={av} title={this.getPowerLabel()} onClick={this.onClick} - name={name} powerStatus={powerStatus} /> + name={name} powerStatus={powerStatus} showPresence={this.props.showPresence} /> ); }, });