Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Access to user presence #228

@tabrza

Description

@tabrza

I'm trying to build out a live chat customer support portal. I need to ensure the user cannot send a message if the support agent is offline. When checking the object in the console, i am able to see the online status of the user and agent. however, when trying to access it in the code it is non-enumerable and gives me a status of undefined (for the agent from the customer side).

i created a function with the following in Customer.js :


checkSupportStatus = () => {
    const { currentRoom, currentUser } = this.state;
    console.log("\n\n\n\n\ test current user",currentUser.rooms[0].users[1].presence);

  }

I plan to use the above function to set a boolean to display a form instead of chat in case the "support" is offline.

the above code is being called in the createRoom function as below:

    const { currentUser } = this.state;
    console.log("create room", currentUser.users);

    currentUser
      .createRoom({
        name: currentUser.name,
        private: true
      })
      .then(room => this.connectToRoom(room.id))
      .then(() => this.addSupportStaffToRoom())
      .then(() => this.checkSupportStatus())
      .catch(console.error);
  };

the object returned is the following:

e {avatarURL: undefined, createdAt: "2020-03-09T08:37:30Z", customData: undefined, id: "support", name: "support", …}
presence: Object
avatarURL: undefined
createdAt: "2020-03-09T08:37:30Z"
customData: undefined
id: "support"
name: "support"
updatedAt: "2020-03-09T08:37:30Z"
presenceStore: {doubtful amethyst impala: "offline", support: "online"}
__proto__: Object

presence appears unenumerable but when clicked shows the correct online status

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions