You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Move getFriendlyDisplayName to RoomMember class. Add more utlity functions.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/**
|
||||
* @module models/room-state
|
||||
*/
|
||||
var utils = require("../utils");
|
||||
|
||||
/**
|
||||
* Construct room state.
|
||||
@@ -21,6 +22,28 @@ function RoomState() {
|
||||
};
|
||||
this.paginationToken = null;
|
||||
}
|
||||
RoomState.prototype = {
|
||||
/**
|
||||
* Get state events from the state of the room.
|
||||
* @param {string} eventType The event type of the state event.
|
||||
* @param {string} stateKey Optional. The state_key of the state event. If
|
||||
* this is <code>undefined</code> then all matching state events will be
|
||||
* returned.
|
||||
* @return {MatrixEvent[]|MatrixEvent} A list of events if state_key was
|
||||
* <code>undefined</code>, else a single event (or null if no match found).
|
||||
*/
|
||||
getStateEvents: function(eventType, stateKey) {
|
||||
if (!this.stateEvents[eventType]) {
|
||||
// no match
|
||||
return stateKey ? null : [];
|
||||
}
|
||||
if (!stateKey) { // return all values
|
||||
return utils.values(this.stateEvents[eventType]);
|
||||
}
|
||||
var event = this.stateEvents[eventType][stateKey];
|
||||
return event ? event : null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The RoomState class.
|
||||
|
||||
Reference in New Issue
Block a user