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

Access to user presence #228

Open
tabrza opened this issue Mar 10, 2020 · 0 comments
Open

Access to user presence #228

tabrza opened this issue Mar 10, 2020 · 0 comments
Labels

Comments

@tabrza
Copy link

tabrza commented Mar 10, 2020

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

@tabrza tabrza added the bug label Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant