Required changes fixed

This commit is contained in:
oobjectt 2022-12-13 21:31:48 +01:00
parent 17d8233381
commit 985fe9be15
2 changed files with 11 additions and 4 deletions

View File

@ -9,7 +9,7 @@ export const ChatHistoryView: FC<{}> = props =>
{ {
const [ isVisible, setIsVisible ] = useState(false); const [ isVisible, setIsVisible ] = useState(false);
const [ searchText, setSearchText ] = useState<string>(''); const [ searchText, setSearchText ] = useState<string>('');
const { chatHistory = [], setMessengerHistory, addMessengerEntry } = useChatHistory(); const { chatHistory = [], setMessengerHistory = null } = useChatHistory();
const { report = null } = useHelp(); const { report = null } = useHelp();
const filteredChatHistory = useMemo(() => const filteredChatHistory = useMemo(() =>
@ -23,9 +23,16 @@ export const ChatHistoryView: FC<{}> = props =>
const reportMessage = (message: any) => const reportMessage = (message: any) =>
{ {
setMessengerHistory([]); // We do this because we are interested in displaying only the reported message. setMessengerHistory(prevValue =>
{
const newValue = [ ...prevValue ];
newValue.push({ id: message.id, webId: message.webId, entityId: message.entityId, name: '', message: message.message, roomId: message.roomId, timestamp: message.timestamp, type: ChatEntryType.TYPE_IM });
return newValue;
});
report(ReportType.IM, { reportedUserId: message.webId }); report(ReportType.IM, { reportedUserId: message.webId });
addMessengerEntry({ id: message.id, webId: message.webId, entityId: message.entityId, name: message.name, timestamp: message.timestamp, type: ChatEntryType.TYPE_IM, roomId: message.roomId, message: message.message });
} }
/* useEffect(() => /* useEffect(() =>

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