Class RoomMember

Typed Event Emitter class which can act as a Base Model for all our model and communication events. This makes it much easier for us to distinguish between events, as we now need to properly type this, so that our events are not stringly-based and prone to silly typos.

Type parameters:

  • Events - List of all events emitted by this TypedEventEmitter. Normally an enum type.
  • Arguments - A ListenerMap type providing mappings from event names to listener types.
  • SuperclassArguments - TODO: not really sure. Alternative listener mappings, I think? But only honoured for .emit?

Hierarchy

Constructors

Properties

_isOutOfBand: boolean = false
disambiguate: boolean = false

True if the member's name is disambiguated.

events: {
    member?: MatrixEvent;
} = {}

The events describing this RoomMember.

Type declaration

  • Optional member?: MatrixEvent

    The m.room.member event for this RoomMember.

membership?: string

The membership state for this room member e.g. 'join'.

modified: number = -1
name: string

The human-readable name for this room member. This will be disambiguated with a suffix of " (@user_id:matrix.org)" if another member shares the same displayname.

powerLevel: number = 0

The power level for this room member.

powerLevelNorm: number = 0

The normalised power level (0-100) for this room member.

rawDisplayName: string

The ambiguous displayname of this room member.

requestedProfileInfo: boolean = false
roomId: string

The room ID of the member.

typing: boolean = false

True if the room member is currently typing.

user?: User

The User object for this room member, if one exists.

userId: string

The user ID of the member.

Methods

  • Get the avatar URL for a room member.

    Parameters

    • baseUrl: string

      The base homeserver URL See getHomeserverUrl.

    • width: number

      The desired width of the thumbnail.

    • height: number

      The desired height of the thumbnail.

    • resizeMethod: string

      The thumbnail resize method to use, either "crop" or "scale".

    • allowDefault: boolean = true

      (optional) Passing false causes this method to return null if the user has no avatar image. Otherwise, a default image URL will be returned. Default: true. (Deprecated)

    • allowDirectLinks: boolean

      (optional) If true, the avatar URL will be returned even if it is a direct hyperlink rather than a matrix content URL. If false, any non-matrix content URLs will be ignored. Setting this option to true will expose URLs that, if fetched, will leak information about the user to anyone who they share a room with.

    Returns null | string

    the avatar URL or null.

  • If this member was invited with the is_direct flag set, return the user that invited this member

    Returns undefined | string

    user id of the inviter

  • Get the timestamp when this RoomMember was last updated. This timestamp is updated when properties on this RoomMember are updated. It is updated before firing events.

    Returns number

    The timestamp

  • get the mxc avatar url, either from a state event, or from a lazily loaded member

    Returns undefined | string

    the mxc avatar url

  • Returns boolean

    does the member come from a channel that is not sync? This is used to store the member seperately from the sync state so it available across browser sessions.

  • Adds the listener function to the end of the listeners array for the event named event.

    No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times.

    By default, event listeners are invoked in the order they are added. The prependListener method can be used as an alternative to add the event listener to the beginning of the listeners array.

    Type Parameters

    Parameters

    Returns RoomMember

    a reference to the EventEmitter, so that calls can be chained.

  • Update this room member's membership event. May fire "RoomMember.name" if this event updates this member's name.

    Parameters

    • event: MatrixEvent

      The m.room.member event

    • Optional roomState: RoomState

      Optional. The room state to take into account when calculating (e.g. for disambiguating users with the same name).

    Returns void

    Remarks

    Fires Name Fires Membership

  • Update this room member's power level event. May fire "RoomMember.powerLevel" if this event updates this member's power levels.

    Parameters

    • powerLevelEvent: MatrixEvent

      The m.room.power_levels event

    Returns void

    Remarks

    Fires PowerLevel

  • Update this room member's typing event. May fire "RoomMember.typing" if this event changes this member's typing state.

    Parameters

    Returns void

    Remarks

    Fires Typing

Generated using TypeDoc