Skip to content

Commit

Permalink
restore player info displayName
Browse files Browse the repository at this point in the history
  • Loading branch information
nikk15 committed Jul 4, 2023
1 parent aec0dc8 commit 9d0b47c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/components/avatar-volume-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AFRAME.registerComponent("avatar-volume-controls", {
this.onRemoteMuteUpdated = this.onRemoteMuteUpdated.bind(this);
this.playerInfo.el.addEventListener("remote_mute_updated", this.onRemoteMuteUpdated);
this.muteButton.object3D.visible = this.playerInfo.data.muted;
const volumePref = getAvatarVolumePref(this.playerInfo.playerSessionId);
const volumePref = getAvatarVolumePref(this.playerInfo.displayName);
this.updateGainMultiplier(volumePref === undefined ? DEFAULT_VOLUME_BAR_MULTIPLIER : volumePref.gainMultiplier);
this.updateLocalMuted(volumePref === undefined ? false : volumePref.muted);
},
Expand All @@ -48,7 +48,7 @@ AFRAME.registerComponent("avatar-volume-controls", {
this.updateVolumeLabel();
this.el.emit("gain_multiplier_updated", { gainMultiplier });
const isLocalMuted = APP.mutedState.has(this.audioEl);
updatePref && updateAvatarVolumesPref(this.playerInfo.playerSessionId, gainMultiplier, isLocalMuted);
updatePref && updateAvatarVolumesPref(this.playerInfo.displayName, gainMultiplier, isLocalMuted);
// If the gainMultiplier is lowered to 0, updated muted status in local storage
if (!gainMultiplier) {
this.updateLocalMuted(true, true);
Expand All @@ -69,7 +69,7 @@ AFRAME.registerComponent("avatar-volume-controls", {
this.el.emit("local_muted_updated", { muted });
const gainMultiplier = APP.gainMultipliers.get(this.audioEl);
const isLocalMuted = APP.mutedState.has(this.audioEl);
updatePref && updateAvatarVolumesPref(this.playerInfo.playerSessionId, gainMultiplier, isLocalMuted);
updatePref && updateAvatarVolumesPref(this.playerInfo.displayName, gainMultiplier, isLocalMuted);
},

volumeUp() {
Expand Down
2 changes: 2 additions & 0 deletions src/components/player-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ AFRAME.registerComponent("player-info", {

this.isLocalPlayerInfo = this.el.id === "avatar-rig";
this.playerSessionId = null;
this.displayName = null;

if (!this.isLocalPlayerInfo) {
NAF.utils.getNetworkedEntity(this.el).then(networkedEntity => {
this.playerSessionId = NAF.utils.getCreator(networkedEntity);
const playerPresence = window.APP.hubChannel.presence.state[this.playerSessionId];
if (playerPresence) {
this.permissions = playerPresence.metas[0].permissions;
this.displayName = playerPresence.metas[0].profile.displayName;
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/react-components/icons/UserSoundOff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/react-components/icons/UserSoundOn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 14 additions & 7 deletions src/react-components/room/PeopleSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,20 @@ export function PeopleSidebar({
{person.hand_raised && <HandRaisedIcon />}
{<DeviceIcon title={getDeviceLabel(person.context, intl)} />}
{!person.context.discord && VoiceIcon && <VoiceIcon title={getVoiceLabel(person.micPresence, intl)} />}
<ToolTip description={getToolTipDescription(store._preferences?.avatarVoiceLevels?.[person.id]?.muted)}>
{store._preferences?.avatarVoiceLevels?.[person.id]?.muted ? (
<UserSoundOffIcon />
) : (
<UserSoundOnIcon />
)}
</ToolTip>
{!person.isMe && (
<ToolTip
classProp="tooltip"
description={getToolTipDescription(
store._preferences?.avatarVoiceLevels?.[person.profile.displayName]?.muted
)}
>
{store._preferences?.avatarVoiceLevels?.[person.profile.displayName]?.muted ? (
<UserSoundOffIcon />
) : (
<UserSoundOnIcon />
)}
</ToolTip>
)}
<p>{getPersonName(person, intl)}</p>
{person.roles.owner && (
<StarIcon
Expand Down
8 changes: 7 additions & 1 deletion src/react-components/room/PeopleSidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:local(.person) {
font-size: theme.$font-size-sm;
color: theme.$text1-color;

position: relative;
& > * {
margin-right: 8px;

Expand All @@ -22,3 +22,9 @@
flex: 1;
justify-content: flex-end;
}

:local(.tooltip) {
z-index: 100;
position: fixed;
position: absolute;
}

0 comments on commit 9d0b47c

Please sign in to comment.