1
0
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:
Kegan Dougal
2015-06-08 12:21:23 +01:00
parent 7ce3a781f3
commit a2257aeb0b
5 changed files with 103 additions and 41 deletions

View File

@@ -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.