Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nikk15 committed Jun 12, 2023
1 parent 6c381b1 commit 8ad607c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
48 changes: 21 additions & 27 deletions src/components/name-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,22 @@ AFRAME.registerComponent("name-tag", {
}
},

updateNametagWidth(name) {
if (name) {
this.pronounsText?.el && this.pronounsText.el.components["text"].getSize(this.size);
const pronounsTextSize = this.size.x || 0;
this.nametagText.el.components["text"].getSize(this.size);
console.log(pronounsTextSize, this.size.x);
this.size.x = Math.max(this.size.x, pronounsTextSize, NAMETAG_MIN_WIDTH);
this.resizeNameTag();
}
},

updateDisplayName() {
if (this.displayName && this.displayName !== this.prevDisplayName) {
this.nametagText.el.addEventListener(
"text-updated",
() => {
if (this.nametagText.el) {
this.nametagText.el.components["text"].getSize(this.size);
this.size.x = Math.max(this.size.x, NAMETAG_MIN_WIDTH);
this.resizeNameTag();
}
},
{ once: true }
);
this.nametagText.el.addEventListener("text-updated", () => this.updateNametagWidth(this.nametagText?.el), {
once: true
});
if (this.displayName.length > DISPLAY_NAME_LENGTH) {
this.displayName = this.displayName.slice(0, DISPLAY_NAME_LENGTH).concat("...");
}
Expand All @@ -246,26 +249,15 @@ AFRAME.registerComponent("name-tag", {

updatePronouns() {
if (this.pronouns !== this.prevPronouns) {
this.pronounsText.el.addEventListener(
"text-updated",
() => {
if (this.pronounsText.el && this.nameTagText.el) {
this.pronounsText.el.components["text"].getSize(this.size);
this.nameTagText.el.components["text"].getSize(this.size);
this.size.x = Math.max(this.size.x, NAMETAG_MIN_WIDTH);
this.resizeNameTag();
}
},
{ once: true }
);
if (this.pronouns.length > this.displayName.length && this.pronouns.length > DISPLAY_NAME_LENGTH) {
this.pronounsText.el.addEventListener("text-updated", () => this.updateNametagWidth(this.nametagText?.el), {
once: true
});
if (this.pronouns.length > DISPLAY_NAME_LENGTH) {
this.pronouns = this.pronouns.slice(0, DISPLAY_NAME_LENGTH).concat("...");
}

this.pronounsText.el.setAttribute("text", {
value: this.pronouns ? `(${this.pronouns})` : ""
});

this.prevPronouns = this.pronouns;
}
},
Expand All @@ -292,8 +284,10 @@ AFRAME.registerComponent("name-tag", {
this.avatarAABBSize.y / 2 +
NAMETAG_OFFSET;
this.nametagElPosY = this.nametagHeight + (this.isHandRaised ? NAMETAG_OFFSET : 0);
this.pronounsText.el && this.pronounsText.el.components["text"].getSize(this.size);
const pronounsTextSize = this.size.x;
this.nametagText.el.components["text"].getSize(this.size);
this.size.x = Math.max(this.size.x, NAMETAG_MIN_WIDTH);
this.size.x = Math.max(this.size.x, pronounsTextSize, NAMETAG_MIN_WIDTH);
this.isAvatarReady = true;

this.updateDisplayName();
Expand Down
2 changes: 1 addition & 1 deletion src/react-components/room/PeopleSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function PeopleSidebar({
filteredPeople.map(person => {
const DeviceIcon = getDeviceIconComponent(person.context);
const VoiceIcon = getVoiceIconComponent(person.micPresence);
console.log(person);

return (
<ButtonListItem
className={styles.person}
Expand Down
2 changes: 1 addition & 1 deletion src/storage/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const SCHEMA = {
properties: {
displayName: { type: "string", pattern: "^[A-Za-z0-9_~ -]{3,32}$" },
avatarId: { type: "string" },
pronouns: { type: "string", pattern: "^[a-z(?:/)a-z]{6,12}$" },
pronouns: { type: "string", pattern: "^[a-zA-Z///a-zA-Z]{2,32}$" },
// personalAvatarId is obsolete, but we need it here for backwards compatibility.
personalAvatarId: { type: "string" }
}
Expand Down

0 comments on commit 8ad607c

Please sign in to comment.