Cleaned up unnecessary lines

This commit is contained in:
oobjectt 2022-12-13 20:15:56 +01:00
parent e5c782a149
commit 2f69e5f2ae
4 changed files with 5 additions and 18 deletions

View File

@ -1,8 +1,8 @@
import { GuideSessionGetRequesterRoomMessageComposer, GuideSessionInviteRequesterMessageComposer, GuideSessionMessageMessageComposer, GuideSessionMessageMessageEvent, GuideSessionRequesterRoomMessageEvent, GuideSessionResolvedMessageComposer } from '@nitrots/nitro-renderer'; import { GuideSessionGetRequesterRoomMessageComposer, GuideSessionInviteRequesterMessageComposer, GuideSessionMessageMessageComposer, GuideSessionRequesterRoomMessageEvent, GuideSessionResolvedMessageComposer } from '@nitrots/nitro-renderer';
import { FC, KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react'; import { FC, KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react';
import { ChatEntryType, ChatHistoryCurrentDate, GetSessionDataManager, GuideToolMessageGroup, LocalizeText, ReportType, SendMessageComposer, TryVisitRoom } from '../../../api'; import { GetSessionDataManager, GuideToolMessageGroup, LocalizeText, ReportType, SendMessageComposer, TryVisitRoom } from '../../../api';
import { Base, Button, ButtonGroup, Column, Flex, LayoutAvatarImageView, Text } from '../../../common'; import { Base, Button, ButtonGroup, Column, Flex, LayoutAvatarImageView, Text } from '../../../common';
import { useChatHistory, useHelp, useMessageEvent, useRoom } from '../../../hooks'; import { useHelp, useMessageEvent } from '../../../hooks';
interface GuideToolOngoingViewProps interface GuideToolOngoingViewProps
{ {
@ -21,8 +21,6 @@ export const GuideToolOngoingView: FC<GuideToolOngoingViewProps> = props =>
const { isGuide = false, userId = 0, userName = null, userFigure = null, isTyping = false, messageGroups = [] } = props; const { isGuide = false, userId = 0, userName = null, userFigure = null, isTyping = false, messageGroups = [] } = props;
const [ messageText, setMessageText ] = useState<string>(''); const [ messageText, setMessageText ] = useState<string>('');
const { addMessengerEntry } = useChatHistory();
const { roomSession = null } = useRoom();
const { report = null } = useHelp(); const { report = null } = useHelp();
useEffect(() => useEffect(() =>
@ -53,13 +51,6 @@ export const GuideToolOngoingView: FC<GuideToolOngoingViewProps> = props =>
TryVisitRoom(parser.requesterRoomId); 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(() => const sendMessage = useCallback(() =>
{ {
if(!messageText || !messageText.length) return; if(!messageText || !messageText.length) return;

View File

@ -14,7 +14,6 @@ export const ReportSummaryView: FC<{}> = props =>
switch(activeReport.reportType) switch(activeReport.reportType)
{ {
case ReportType.BULLY: case ReportType.BULLY:
case ReportType.EMERGENCY: case ReportType.EMERGENCY:
case ReportType.ROOM: { case ReportType.ROOM: {
@ -40,9 +39,7 @@ export const ReportSummaryView: FC<{}> = props =>
SendMessageComposer(new CallForHelpFromPhotoMessageComposer(activeReport.extraData, activeReport.cfhTopic, activeReport.roomId, GetSessionDataManager().userId, activeReport.roomObjectId)); SendMessageComposer(new CallForHelpFromPhotoMessageComposer(activeReport.extraData, activeReport.cfhTopic, activeReport.roomId, GetSessionDataManager().userId, activeReport.roomObjectId));
break; break;
case ReportType.GUIDE: case ReportType.GUIDE:
activeReport.reportedChats.forEach(entry => chats.push(entry.webId, entry.message)); SendMessageComposer(new GuideSessionReportMessageComposer(''));
SendMessageComposer(new GuideSessionReportMessageComposer(activeReport.message));
break; break;
} }

View File

@ -18,7 +18,6 @@ export const SelectReportedChatsView: FC<{}> = props =>
case ReportType.EMERGENCY: case ReportType.EMERGENCY:
return chatHistory.filter(chat => (chat.type === ChatEntryType.TYPE_CHAT) && (chat.webId === activeReport.reportedUserId) && (chat.entityType === RoomObjectType.USER)); return chatHistory.filter(chat => (chat.type === ChatEntryType.TYPE_CHAT) && (chat.webId === activeReport.reportedUserId) && (chat.entityType === RoomObjectType.USER));
case ReportType.IM: case ReportType.IM:
case ReportType.GUIDE:
return messengerHistory.filter(chat => (chat.webId === activeReport.reportedUserId) && (chat.type === ChatEntryType.TYPE_IM)); return messengerHistory.filter(chat => (chat.webId === activeReport.reportedUserId) && (chat.type === ChatEntryType.TYPE_IM));
} }

View File

@ -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 }); 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, addMessengerEntry }; return { addChatEntry, chatHistory, roomHistory, messengerHistory };
} }
export const useChatHistory = () => useBetween(useChatHistoryState); export const useChatHistory = () => useBetween(useChatHistoryState);