Skip to content

Commit

Permalink
Make optional author override on incoming chat
Browse files Browse the repository at this point in the history
  • Loading branch information
mqp committed Jan 10, 2019
1 parent 8484045 commit cf8865d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,22 @@ document.addEventListener("DOMContentLoaded", async () => {
NAF.connection.adapter.onData(data);
});

hubPhxChannel.on("message", ({ session_id, type, body }) => {
const userInfo = hubPhxPresence.state[session_id];
if (!userInfo) return;
hubPhxChannel.on("message", ({ session_id, type, body, from }) => {
const getAuthor = () => {
const userInfo = hubPhxPresence.state[session_id];
if (from) {
return from;
} else if (userInfo) {
return userInfo.metas[0].profile.displayName;
} else {
return "Mystery user";
}
};

const name = getAuthor();
const maySpawn = scene.is("entered");

const incomingMessage = { name: userInfo.metas[0].profile.displayName, type, body, maySpawn };
const incomingMessage = { name, type, body, maySpawn };

if (scene.is("vr-mode")) {
createInWorldLogMessage(incomingMessage);
Expand Down

0 comments on commit cf8865d

Please sign in to comment.