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

Commit a4ee1a2

Browse files
committed
override enable_presence_by_Hs_url with capabilities
1 parent 111b289 commit a4ee1a2

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/components/views/rooms/MemberInfo.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ module.exports = withMatrixClient(React.createClass({
8989
cli.on("RoomMember.membership", this.onRoomMemberMembership);
9090
cli.on("accountData", this.onAccountData);
9191

92+
const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"];
93+
this._showPresence = true;
94+
if (enablePresenceByHsUrl && enablePresenceByHsUrl[cli.baseUrl] !== undefined) {
95+
this._showPresence = enablePresenceByHsUrl[cli.baseUrl];
96+
}
97+
cli.getCapabilities().then((caps) => {
98+
if (!caps["m.presence"]) {
99+
return;
100+
}
101+
this._showPresence = caps["m.presence"]["receive_enabled"];
102+
});
92103
this._checkIgnoreState();
93104
},
94105

@@ -922,15 +933,8 @@ module.exports = withMatrixClient(React.createClass({
922933
const powerLevelEvent = room ? room.currentState.getStateEvents("m.room.power_levels", "") : null;
923934
const powerLevelUsersDefault = powerLevelEvent ? powerLevelEvent.getContent().users_default : 0;
924935

925-
const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"];
926-
const hsUrl = this.props.matrixClient.baseUrl;
927-
let showPresence = true;
928-
if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) {
929-
showPresence = enablePresenceByHsUrl[hsUrl];
930-
}
931-
932936
let presenceLabel = null;
933-
if (showPresence) {
937+
if (this._showPresence) {
934938
const PresenceLabel = sdk.getComponent('rooms.PresenceLabel');
935939
presenceLabel = <PresenceLabel activeAgo={presenceLastActiveAgo}
936940
currentlyActive={presenceCurrentlyActive}

src/components/views/rooms/MemberList.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ module.exports = React.createClass({
5555
}
5656
cli.on("Room", this.onRoom); // invites & joining after peek
5757
const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"];
58-
const hsUrl = MatrixClientPeg.get().baseUrl;
5958
this._showPresence = true;
60-
if (enablePresenceByHsUrl && enablePresenceByHsUrl[hsUrl] !== undefined) {
61-
this._showPresence = enablePresenceByHsUrl[hsUrl];
59+
if (enablePresenceByHsUrl && enablePresenceByHsUrl[cli.baseUrl] !== undefined) {
60+
this._showPresence = enablePresenceByHsUrl[cli.baseUrl];
6261
}
62+
cli.getCapabilities().then((caps) => {
63+
if (!caps["m.presence"]) {
64+
return;
65+
}
66+
this._showPresence = caps["m.presence"]["receive_enabled"];
67+
});
6368
},
6469

6570
_listenForMembersChanges: function() {

0 commit comments

Comments
 (0)