1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-11 19:37:30 +03:00

provide method on room to help with DM detection with fallback to summary heroes/counts.

This commit is contained in:
Bruno Windels
2018-08-02 11:38:58 +02:00
parent f55a2079bf
commit a8d0d8f33d

View File

@@ -240,6 +240,21 @@ Room.prototype.getMyMembership = function() {
return this._syncedMembership;
};
Room.prototype.getDMInviter = function() {
if (this.myUserId) {
const me = this.getMember(this.myUserId);
if (me) {
return me.getDMInviter();
}
}
// fall back to summary information
const memberCount = room.currentState.getJoinedMemberCount() +
room.currentState.getInvitedMemberCount();
if (memberCount == 2 && this._summaryHeroes.length) {
return this._summaryHeroes[0];
}
}
/**
* Sets the membership this room was received as during sync
* @param {string} membership join | leave | invite