mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-19 05:46:27 +01:00
Fix issue #11 - Report user guide
This commit is contained in:
parent
b479210aca
commit
e03fa83bf7
@ -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<GuideToolOngoingViewProps> = props =>
|
||||
const { isGuide = false, userId = 0, userName = null, userFigure = null, isTyping = false, messageGroups = [] } = props;
|
||||
|
||||
const [ messageText, setMessageText ] = useState<string>('');
|
||||
const { addMessengerEntry } = useChatHistory();
|
||||
const { roomSession = null } = useRoom();
|
||||
const { report = null } = useHelp();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
@ -50,6 +53,13 @@ export const GuideToolOngoingView: FC<GuideToolOngoingViewProps> = props =>
|
||||
TryVisitRoom(parser.requesterRoomId);
|
||||
});
|
||||
|
||||
useMessageEvent<GuideSessionMessageMessageEvent>(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<GuideToolOngoingViewProps> = props =>
|
||||
<Text bold>{ userName }</Text>
|
||||
<Text>{ LocalizeText('guide.help.request.user.ongoing.guide.desc') }</Text>
|
||||
</Column> }
|
||||
<Button variant="danger" disabled>{ LocalizeText('guide.help.common.report.link') }</Button>
|
||||
<Button variant="danger" disabled={ messageGroups.length === 0 } onClick={ () => report(ReportType.IM, { reportedUserId: userId }) }>{ LocalizeText('guide.help.common.report.link') }</Button>
|
||||
</Flex>
|
||||
<Column overflow="hidden" gap={ 1 } className="bg-muted rounded chat-messages p-2">
|
||||
<Column overflow="auto">
|
||||
|
@ -98,7 +98,7 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user