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

Hide/show presence based on capabilities per MSC1862 #3208

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/components/views/rooms/MemberInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ module.exports = withMatrixClient(React.createClass({
cli.on("RoomMember.membership", this.onRoomMemberMembership);
cli.on("accountData", this.onAccountData);

const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"];
this._showPresence = true;
if (enablePresenceByHsUrl && enablePresenceByHsUrl[cli.baseUrl] !== undefined) {
this._showPresence = enablePresenceByHsUrl[cli.baseUrl];
}
cli.getCapabilities().then((caps) => {
if (!caps["m.presence"]) {
return;
}
this._showPresence = caps["m.presence"]["receive_enabled"];
});
this._checkIgnoreState();
},

Expand Down Expand Up @@ -922,15 +933,8 @@ 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) {
if (this._showPresence) {
const PresenceLabel = sdk.getComponent('rooms.PresenceLabel');
presenceLabel = <PresenceLabel activeAgo={presenceLastActiveAgo}
currentlyActive={presenceCurrentlyActive}
Expand Down
11 changes: 8 additions & 3 deletions src/components/views/rooms/MemberList.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ module.exports = React.createClass({
}
cli.on("Room", this.onRoom); // invites & joining after peek
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];
if (enablePresenceByHsUrl && enablePresenceByHsUrl[cli.baseUrl] !== undefined) {
this._showPresence = enablePresenceByHsUrl[cli.baseUrl];
}
cli.getCapabilities().then((caps) => {
if (!caps["m.presence"]) {
return;
}
this._showPresence = caps["m.presence"]["receive_enabled"];
});
},

_listenForMembersChanges: function() {
Expand Down