Class User

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.

Hierarchy

Constructors

Properties

avatarUrl?: string

The 'avatar_url' of the user if known.

currentlyActive: boolean = false

Whether we should consider lastActiveAgo to be an approximation and that the user should be seen as active 'now'

displayName?: string

The 'displayname' of the user if known.

events: {
    presence?: MatrixEvent;
    profile?: MatrixEvent;
} = {}

The events describing this user.

Type declaration

lastActiveAgo: number = 0

Timestamp (ms since the epoch) for when we last received presence data for this user. We can subtract lastActiveAgo from this to approximate an absolute value for when a user was last active.

lastPresenceTs: number = 0

The time elapsed in ms since the user interacted proactively with the server, or we saw a message from the user

modified: number = -1
presence: string = "offline"

The presence enum if known.

presenceStatusMsg?: string

The presence status message if known.

rawDisplayName?: string
userId: string

Required. The ID of this user.

Methods

  • Get the absolute timestamp when this User was last known active on the server. It is NOT accurate if this.currentlyActive is true.

    Returns

    The timestamp

    Returns number

  • Get the timestamp when this User was last updated. This timestamp is updated when this User receives a new Presence event which has updated a property on this object. It is updated before firing events.

    Returns

    The timestamp

    Returns number

  • Manually set this user's avatar URL. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.

    Parameters

    • Optional url: string

      The new avatar URL.

    Returns void

  • Manually set this user's display name. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.

    Parameters

    • name: string

      The new display name.

    Returns void

  • Update this User with the given presence event. May fire "User.presence", "User.avatarUrl" and/or "User.displayName" if this event updates this user's properties.

    Remarks

    Fires Presence Fires DisplayName Fires AvatarUrl

    Parameters

    Returns void

  • Manually set this user's non-disambiguated display name. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.

    Parameters

    • Optional name: string

      The new display name.

    Returns void

  • Update the last modified time to the current time.

    Returns void

Generated using TypeDoc