Merge branch 'Gurkengewuerz:main' into main

This commit is contained in:
duckietm 2023-03-24 16:09:03 +01:00 committed by GitHub
commit 6a6c5d20a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -12,17 +12,18 @@ export const ChatHistoryView: FC<{}> = props => {
const elementRef = useRef<HTMLDivElement>(null);
const filteredChatHistory = useMemo(() => {
if (searchText.length === 0) return chatHistory;
const sortedChatHistory = chatHistory.sort((a, b) => b.id - a.id);
if (searchText.length === 0) return sortedChatHistory;
let text = searchText.toLowerCase();
return chatHistory
.filter(entry => (entry.message && entry.message.toLowerCase().includes(text)) || (entry.name && entry.name.toLowerCase().includes(text)))
.sort((a, b) => b.id - a.id);
return sortedChatHistory
.filter(entry => (entry.message && entry.message.toLowerCase().includes(text)) || (entry.name && entry.name.toLowerCase().includes(text)));
}, [chatHistory, searchText]);
useEffect(() => {
if (elementRef && elementRef.current && isVisible) elementRef.current.scrollTop = elementRef.current.scrollHeight;
if (elementRef && elementRef.current && isVisible) elementRef.current.scrollTop = 0;
}, [isVisible]);
useEffect(() => {
@ -67,7 +68,7 @@ export const ChatHistoryView: FC<{}> = props => {
/>
<InfiniteScroll
rows={filteredChatHistory}
scrollToBottom={true}
scrollToBottom={false}
rowRender={row => {
return (
<Flex alignItems="center" className="p-1" gap={2}>