Merge pull request #1806 from matrix-org/dbkr/lets_kill_presence
Option to remove the presence feature by HS
This commit is contained in:
commit
eb52487b6d
4 changed files with 59 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2018 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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
|
// offline is split into two categories depending on whether we have
|
||||||
// a last_active_ago for them.
|
// a last_active_ago for them.
|
||||||
if (presenceState == 'offline') {
|
if (presenceState == 'offline') {
|
||||||
|
@ -64,6 +69,7 @@ const EntityTile = React.createClass({
|
||||||
shouldComponentUpdate: PropTypes.func,
|
shouldComponentUpdate: PropTypes.func,
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
suppressOnHover: PropTypes.bool,
|
suppressOnHover: PropTypes.bool,
|
||||||
|
showPresence: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -75,6 +81,7 @@ const EntityTile = React.createClass({
|
||||||
presenceLastTs: 0,
|
presenceLastTs: 0,
|
||||||
showInviteButton: false,
|
showInviteButton: false,
|
||||||
suppressOnHover: false,
|
suppressOnHover: false,
|
||||||
|
showPresence: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -99,7 +106,7 @@ const EntityTile = React.createClass({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const presenceClass = presenceClassForMember(
|
const presenceClass = presenceClassForMember(
|
||||||
this.props.presenceState, this.props.presenceLastActiveAgo,
|
this.props.presenceState, this.props.presenceLastActiveAgo, this.props.showPresence,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mainClassName = "mx_EntityTile ";
|
let mainClassName = "mx_EntityTile ";
|
||||||
|
@ -114,15 +121,21 @@ const EntityTile = React.createClass({
|
||||||
|
|
||||||
mainClassName += " mx_EntityTile_hover";
|
mainClassName += " mx_EntityTile_hover";
|
||||||
const PresenceLabel = sdk.getComponent("rooms.PresenceLabel");
|
const PresenceLabel = sdk.getComponent("rooms.PresenceLabel");
|
||||||
|
let presenceLabel = null;
|
||||||
|
let nameClasses = 'mx_EntityTile_name';
|
||||||
|
if (this.props.showPresence) {
|
||||||
|
presenceLabel = <PresenceLabel activeAgo={activeAgo}
|
||||||
|
currentlyActive={this.props.presenceCurrentlyActive}
|
||||||
|
presenceState={this.props.presenceState} />;
|
||||||
|
nameClasses += ' mx_EntityTile_name_hover';
|
||||||
|
}
|
||||||
nameEl = (
|
nameEl = (
|
||||||
<div className="mx_EntityTile_details">
|
<div className="mx_EntityTile_details">
|
||||||
<img className="mx_EntityTile_chevron" src="img/member_chevron.png" width="8" height="12" />
|
<img className="mx_EntityTile_chevron" src="img/member_chevron.png" width="8" height="12" />
|
||||||
<EmojiText element="div" className="mx_EntityTile_name mx_EntityTile_name_hover" dir="auto">
|
<EmojiText element="div" className={nameClasses} dir="auto">
|
||||||
{ name }
|
{ name }
|
||||||
</EmojiText>
|
</EmojiText>
|
||||||
<PresenceLabel activeAgo={activeAgo}
|
{presenceLabel}
|
||||||
currentlyActive={this.props.presenceCurrentlyActive}
|
|
||||||
presenceState={this.props.presenceState} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
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");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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 AccessibleButton from '../elements/AccessibleButton';
|
||||||
import GeminiScrollbar from 'react-gemini-scrollbar';
|
import GeminiScrollbar from 'react-gemini-scrollbar';
|
||||||
import RoomViewStore from '../../../stores/RoomViewStore';
|
import RoomViewStore from '../../../stores/RoomViewStore';
|
||||||
|
import SdkConfig from '../../../SdkConfig';
|
||||||
|
|
||||||
module.exports = withMatrixClient(React.createClass({
|
module.exports = withMatrixClient(React.createClass({
|
||||||
displayName: 'MemberInfo',
|
displayName: 'MemberInfo',
|
||||||
|
@ -861,6 +862,20 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
const powerLevelEvent = room ? room.currentState.getStateEvents("m.room.power_levels", "") : null;
|
const powerLevelEvent = room ? room.currentState.getStateEvents("m.room.power_levels", "") : null;
|
||||||
const powerLevelUsersDefault = powerLevelEvent ? powerLevelEvent.getContent().users_default : 0;
|
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 = <PresenceLabel activeAgo={presenceLastActiveAgo}
|
||||||
|
currentlyActive={presenceCurrentlyActive}
|
||||||
|
presenceState={presenceState} />;
|
||||||
|
}
|
||||||
|
|
||||||
let roomMemberDetails = null;
|
let roomMemberDetails = null;
|
||||||
if (this.props.member.roomId) { // is in room
|
if (this.props.member.roomId) { // is in room
|
||||||
const PowerSelector = sdk.getComponent('elements.PowerSelector');
|
const PowerSelector = sdk.getComponent('elements.PowerSelector');
|
||||||
|
@ -877,9 +892,7 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
</b>
|
</b>
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_MemberInfo_profileField">
|
<div className="mx_MemberInfo_profileField">
|
||||||
<PresenceLabel activeAgo={presenceLastActiveAgo}
|
{presenceLabel}
|
||||||
currentlyActive={presenceCurrentlyActive}
|
|
||||||
presenceState={presenceState} />
|
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
Copyright 2017 Vector Creations 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");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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 React from 'react';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
|
import SdkConfig from '../../../SdkConfig';
|
||||||
const MatrixClientPeg = require("../../../MatrixClientPeg");
|
const MatrixClientPeg = require("../../../MatrixClientPeg");
|
||||||
const sdk = require('../../../index');
|
const sdk = require('../../../index');
|
||||||
const GeminiScrollbar = require('react-gemini-scrollbar');
|
const GeminiScrollbar = require('react-gemini-scrollbar');
|
||||||
|
@ -59,6 +60,14 @@ module.exports = React.createClass({
|
||||||
// the information contained in presence events).
|
// the information contained in presence events).
|
||||||
cli.on("User.lastPresenceTs", this.onUserLastPresenceTs);
|
cli.on("User.lastPresenceTs", this.onUserLastPresenceTs);
|
||||||
// cli.on("Room.timeline", this.onRoomTimeline);
|
// 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() {
|
componentWillUnmount: function() {
|
||||||
|
@ -345,7 +354,7 @@ module.exports = React.createClass({
|
||||||
const memberList = members.map((userId) => {
|
const memberList = members.map((userId) => {
|
||||||
const m = this.memberDict[userId];
|
const m = this.memberDict[userId];
|
||||||
return (
|
return (
|
||||||
<MemberTile key={userId} member={m} ref={userId} />
|
<MemberTile key={userId} member={m} ref={userId} showPresence={this._showPresence} />
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -358,7 +367,10 @@ module.exports = React.createClass({
|
||||||
if (membership === "invite") {
|
if (membership === "invite") {
|
||||||
const EntityTile = sdk.getComponent("rooms.EntityTile");
|
const EntityTile = sdk.getComponent("rooms.EntityTile");
|
||||||
memberList.push(...this._getPending3PidInvites().map((e) => {
|
memberList.push(...this._getPending3PidInvites().map((e) => {
|
||||||
return <EntityTile key={e.getStateKey()} name={e.getContent().display_name} suppressOnHover={true} />;
|
return <EntityTile key={e.getStateKey()}
|
||||||
|
name={e.getContent().display_name}
|
||||||
|
suppressOnHover={true}
|
||||||
|
/>;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,13 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
member: PropTypes.any.isRequired, // RoomMember
|
member: PropTypes.any.isRequired, // RoomMember
|
||||||
|
showPresence: PropTypes.bool,
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultProps: function() {
|
||||||
|
return {
|
||||||
|
showPresence: true,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -99,7 +106,7 @@ module.exports = React.createClass({
|
||||||
presenceLastTs={member.user ? member.user.lastPresenceTs : 0}
|
presenceLastTs={member.user ? member.user.lastPresenceTs : 0}
|
||||||
presenceCurrentlyActive={member.user ? member.user.currentlyActive : false}
|
presenceCurrentlyActive={member.user ? member.user.currentlyActive : false}
|
||||||
avatarJsx={av} title={this.getPowerLabel()} onClick={this.onClick}
|
avatarJsx={av} title={this.getPowerLabel()} onClick={this.onClick}
|
||||||
name={name} powerStatus={powerStatus} />
|
name={name} powerStatus={powerStatus} showPresence={this.props.showPresence} />
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue