From e03fa83bf781828af62e5a9816fbbb378c361ed0 Mon Sep 17 00:00:00 2001 From: oobjectt Date: Thu, 8 Dec 2022 16:43:51 +0100 Subject: [PATCH] Fix issue #11 - Report user guide --- .../guide-tool/views/GuideToolOngoingView.tsx | 18 ++++++++++++++---- src/hooks/chat-history/useChatHistory.ts | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/guide-tool/views/GuideToolOngoingView.tsx b/src/components/guide-tool/views/GuideToolOngoingView.tsx index 080de332..b1b6dee2 100644 --- a/src/components/guide-tool/views/GuideToolOngoingView.tsx +++ b/src/components/guide-tool/views/GuideToolOngoingView.tsx @@ -1,8 +1,8 @@ -import { GuideSessionGetRequesterRoomMessageComposer, GuideSessionInviteRequesterMessageComposer, GuideSessionMessageMessageComposer, GuideSessionRequesterRoomMessageEvent, GuideSessionResolvedMessageComposer } from '@nitrots/nitro-renderer'; +import { GuideSessionGetRequesterRoomMessageComposer, GuideSessionInviteRequesterMessageComposer, GuideSessionMessageMessageComposer, GuideSessionMessageMessageEvent, GuideSessionRequesterRoomMessageEvent, GuideSessionResolvedMessageComposer } from '@nitrots/nitro-renderer'; import { FC, KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react'; -import { GetSessionDataManager, GuideToolMessageGroup, LocalizeText, SendMessageComposer, TryVisitRoom } from '../../../api'; +import { ChatEntryType, ChatHistoryCurrentDate, GetSessionDataManager, GuideToolMessageGroup, LocalizeText, ReportType, SendMessageComposer, TryVisitRoom } from '../../../api'; import { Base, Button, ButtonGroup, Column, Flex, LayoutAvatarImageView, Text } from '../../../common'; -import { useMessageEvent } from '../../../hooks'; +import { useChatHistory, useHelp, useMessageEvent, useRoom } from '../../../hooks'; interface GuideToolOngoingViewProps { @@ -21,6 +21,9 @@ export const GuideToolOngoingView: FC = props => const { isGuide = false, userId = 0, userName = null, userFigure = null, isTyping = false, messageGroups = [] } = props; const [ messageText, setMessageText ] = useState(''); + const { addMessengerEntry } = useChatHistory(); + const { roomSession = null } = useRoom(); + const { report = null } = useHelp(); useEffect(() => { @@ -50,6 +53,13 @@ export const GuideToolOngoingView: FC = props => TryVisitRoom(parser.requesterRoomId); }); + useMessageEvent(GuideSessionMessageMessageEvent, event => + { + const parser = event.getParser(); + + addMessengerEntry({ id: -1, webId: parser.senderId, entityId: -1, name: userName, timestamp: ChatHistoryCurrentDate(), type: ChatEntryType.TYPE_IM, roomId: !roomSession ? 0 : roomSession.roomId, message: parser.chatMessage }); + }); + const sendMessage = useCallback(() => { if(!messageText || !messageText.length) return; @@ -83,7 +93,7 @@ export const GuideToolOngoingView: FC = props => { userName } { LocalizeText('guide.help.request.user.ongoing.guide.desc') } } - + diff --git a/src/hooks/chat-history/useChatHistory.ts b/src/hooks/chat-history/useChatHistory.ts index a2f3c346..d1e632da 100644 --- a/src/hooks/chat-history/useChatHistory.ts +++ b/src/hooks/chat-history/useChatHistory.ts @@ -97,8 +97,8 @@ const useChatHistoryState = () => addMessengerEntry({ id: -1, webId: parser.senderId, entityId: -1, name: '', message: parser.messageText, roomId: -1, timestamp: MessengerHistoryCurrentDate(), type: ChatEntryType.TYPE_IM }); }); - - return { addChatEntry, chatHistory, roomHistory, messengerHistory }; + + return { addChatEntry, chatHistory, roomHistory, messengerHistory, addMessengerEntry }; } export const useChatHistory = () => useBetween(useChatHistoryState);