src/models/room-state.js
function RoomState(roomId, oobMemberFlags = undefined) {
    this.roomId = roomId;
    this.members = {
        // userId: RoomMember
    };
    this.events = {
        // eventType: { stateKey: MatrixEvent }
    };
    this.paginationToken = null;

    this._sentinels = {
        // userId: RoomMember
    };
    this._updateModifiedTime();

    // stores fuzzy matches to a list of userIDs (applies utils.removeHiddenChars to keys)
    this._displayNameToUserIds = {};
    this._userIdsToDisplayNames = {};
    this._tokenToInvite = {}; // 3pid invite state_key to m.room.member invite
    this._joinedMemberCount = null; // cache of the number of joined members
    // joined members count from summary api
    // once set, we know the server supports the summary api
    // and we should only trust that
    // we could also only trust that before OOB members
    // are loaded but doesn't seem worth the hassle atm
    this._summaryJoinedMemberCount = null;
    // same for invited member count
    this._invitedMemberCount = null;
    this._summaryInvitedMemberCount = null;

    if (!oobMemberFlags) {
        oobMemberFlags = {
            status: OOB_STATUS_NOTSTARTED,
        };
    }
    this._oobMemberFlags = oobMemberFlags;
}
function RoomState(roomId, oobMemberFlags = undefined) {
    this.roomId = roomId;
    this.members = {
        // userId: RoomMember
    };
    this.events = {
        // eventType: { stateKey: MatrixEvent }
    };
    this.paginationToken = null;

    this._sentinels = {
        // userId: RoomMember
    };
    this._updateModifiedTime();

    // stores fuzzy matches to a list of userIDs (applies utils.removeHiddenChars to keys)
    this._displayNameToUserIds = {};
    this._userIdsToDisplayNames = {};
    this._tokenToInvite = {}; // 3pid invite state_key to m.room.member invite
    this._joinedMemberCount = null; // cache of the number of joined members
    // joined members count from summary api
    // once set, we know the server supports the summary api
    // and we should only trust that
    // we could also only trust that before OOB members
    // are loaded but doesn't seem worth the hassle atm
    this._summaryJoinedMemberCount = null;
    // same for invited member count
    this._invitedMemberCount = null;
    this._summaryInvitedMemberCount = null;

    if (!oobMemberFlags) {
        oobMemberFlags = {
            status: OOB_STATUS_NOTSTARTED,
        };
    }
    this._oobMemberFlags = oobMemberFlags;
}
function RoomState ( roomId , oobMemberFlags = undefined ) { this . roomId = roomId ; this . members = { // userId: RoomMember } ; this . events = { // eventType: { stateKey: MatrixEvent } } ; this . paginationToken = null ; this . _sentinels = { // userId: RoomMember } ; this . _updateModifiedTime ( ) ; // stores fuzzy matches to a list of userIDs (applies utils.removeHiddenChars to keys) this . _displayNameToUserIds = { } ; this . _userIdsToDisplayNames = { } ; this . _tokenToInvite = { } ; // 3pid invite state_key to m.room.member invite this . _joinedMemberCount = null ; // cache of the number of joined members // joined members count from summary api // once set, we know the server supports the summary api // and we should only trust that // we could also only trust that before OOB members // are loaded but doesn't seem worth the hassle atm this . _summaryJoinedMemberCount = null ; // same for invited member count this . _invitedMemberCount = null ; this . _summaryInvitedMemberCount = null ; if ( ! oobMemberFlags ) { oobMemberFlags = { status : OOB_STATUS_NOTSTARTED , } ; } this . _oobMemberFlags = oobMemberFlags ; }
Construct room state.

Room State represents the state of the room at a given point.
It can be mutated by adding state events to it.
There are two types of room member associated with a state event:
normal member objects (accessed via getMember/getMembers) which mutate
with the state to represent the current state of that room/user, eg.
the object returned by getMember('@bob:example.com') will mutate to
get a different display name if Bob later changes his display name
in the room.
There are also 'sentinel' members (accessed via getSentinelMember).
These also represent the state of room members at the point in time
represented by the RoomState object, but unlike objects from getMember,
sentinel objects will always represent the room state as at the time
getSentinelMember was called, so if Bob subsequently changes his display
name, a room member object previously acquired with getSentinelMember
will still have his old display name. Calling getSentinelMember again
after the display name change will return a new RoomMember object
with Bob's new display name.

@constructor
@param {?string} roomId Optional. The ID of the room which has this state.
If none is specified it just tracks paginationTokens, useful for notifTimelineSet
@param {?object} oobMemberFlags Optional. The state of loading out of bound members.
As the timeline might get reset while they are loading, this state needs to be inherited
and shared when the room state is cloned for the new timeline.
This should only be passed from clone.
@prop {Object.<string, RoomMember>} members The room member dictionary, keyed
on the user's ID.
@prop {Object.<string, Object.<string, MatrixEvent>>} events The state
events dictionary, keyed on the event type and then the state_key value.
@prop {string} paginationToken The pagination token for this state.
Construct room state .