From 33a40ddb7dcee64e8f188200c95de3f1716e6d8d Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 20 Jul 2022 01:31:42 -0400 Subject: [PATCH] Fix chat input selected user --- src/hooks/rooms/widgets/useChatInputWidget.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/hooks/rooms/widgets/useChatInputWidget.ts b/src/hooks/rooms/widgets/useChatInputWidget.ts index 970b17da..51761d43 100644 --- a/src/hooks/rooms/widgets/useChatInputWidget.ts +++ b/src/hooks/rooms/widgets/useChatInputWidget.ts @@ -1,7 +1,8 @@ -import { AvatarExpressionEnum, HabboClubLevelEnum, RoomControllerLevel, RoomEngineObjectEvent, RoomRotatingEffect, RoomSessionChatEvent, RoomSettingsComposer, RoomShakingEffect, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer'; +import { AvatarExpressionEnum, HabboClubLevelEnum, RoomControllerLevel, RoomEngineObjectEvent, RoomObjectCategory, RoomRotatingEffect, RoomSessionChatEvent, RoomSettingsComposer, RoomShakingEffect, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer'; import { useEffect, useState } from 'react'; import { ChatMessageTypeEnum, CreateLinkEvent, GetClubMemberLevel, GetConfiguration, GetNitroInstance, GetRoomEngine, GetSessionDataManager, LocalizeText, NotificationUtilities, SendMessageComposer } from '../../../api'; import { useRoomEngineEvent, useRoomSessionManagerEvent } from '../../events'; +import { useObjectSelectedEvent } from '../engine'; import { useRoom } from '../useRoom'; const useChatInputWidgetState = () => @@ -181,7 +182,16 @@ const useChatInputWidgetState = () => setFloodBlockedSeconds(parseFloat(event.message)); }); - //useUiEvent(InfostandUserInfo.PEER, event => setSelectedUsername(event.name)); + useObjectSelectedEvent(event => + { + if(event.category !== RoomObjectCategory.UNIT) return; + + const userData = roomSession.userDataManager.getUserDataByIndex(event.id); + + if(!userData) return; + + setSelectedUsername(userData.name); + }); useRoomEngineEvent(RoomEngineObjectEvent.DESELECTED, event => setSelectedUsername(''));