From 88823300af59a962db578e478b4dd2af00df5566 Mon Sep 17 00:00:00 2001 From: oobjectt Date: Tue, 20 Dec 2022 23:55:05 +0100 Subject: [PATCH] Added action for pet commands --- .../pet-training/PetTrainingPanelWidgetView.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/room/widgets/pet-training/PetTrainingPanelWidgetView.tsx b/src/components/room/widgets/pet-training/PetTrainingPanelWidgetView.tsx index 170f2332..22d95cc0 100644 --- a/src/components/room/widgets/pet-training/PetTrainingPanelWidgetView.tsx +++ b/src/components/room/widgets/pet-training/PetTrainingPanelWidgetView.tsx @@ -2,11 +2,13 @@ import { DesktopViewEvent, PetTrainingPanelMessageEvent } from '@nitrots/nitro-r import { FC } from 'react'; import { AvatarInfoPet, LocalizeText } from '../../../../api'; import { Button, Column, Flex, Grid, LayoutPetImageView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; -import { useAvatarInfoWidget, useMessageEvent } from '../../../../hooks'; +import { useAvatarInfoWidget, useMessageEvent, useRoom, useSessionInfo } from '../../../../hooks'; export const PetTrainingPanelWidgetView: FC<{}> = props => { const { avatarInfo = null, petTrainInformation = null, setPetTrainInformation = null } = useAvatarInfoWidget(); + const { chatStyleId = 0 } = useSessionInfo(); + const { roomSession = null } = useRoom(); useMessageEvent(DesktopViewEvent, event => { @@ -22,11 +24,11 @@ export const PetTrainingPanelWidgetView: FC<{}> = props => setPetTrainInformation(parser); }); - const processPetAction = (petId: number, type: string) => + const processPetAction = (petName: string, commandName: string) => { - if (!petId || !type) return; + if (!petName || !commandName) return; - // packet for pet actions + roomSession?.sendChatMessage(`${ petName } ${ commandName }`, chatStyleId); } if(!petTrainInformation) return null; @@ -46,7 +48,7 @@ export const PetTrainingPanelWidgetView: FC<{}> = props => { (petTrainInformation.commands && petTrainInformation.commands.length > 0) && petTrainInformation.commands.map((command, index) => - + ) }