mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
fix: throttle scroll to bottom
This commit is contained in:
parent
4ce60537ca
commit
4cd0ff2682
2 changed files with 4 additions and 3 deletions
|
|
@ -49,7 +49,6 @@ const inLineWrap = (parts) => {
|
||||||
export default function TextWrapper({ text, generateCursor }) {
|
export default function TextWrapper({ text, generateCursor }) {
|
||||||
let embedTest = false;
|
let embedTest = false;
|
||||||
let result = null;
|
let result = null;
|
||||||
console.log('text wrapper', text)
|
|
||||||
|
|
||||||
// to match unenclosed code blocks
|
// to match unenclosed code blocks
|
||||||
if (text.match(/```/g)?.length === 1) {
|
if (text.match(/```/g)?.length === 1) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { useEffect, useState, useRef, useCallback } from 'react';
|
import React, { useEffect, useState, useRef, useCallback } from 'react';
|
||||||
import Spinner from '../svg/Spinner';
|
import Spinner from '../svg/Spinner';
|
||||||
|
import { throttle } from 'lodash';
|
||||||
import { CSSTransition } from 'react-transition-group';
|
import { CSSTransition } from 'react-transition-group';
|
||||||
import ScrollToBottom from './ScrollToBottom';
|
import ScrollToBottom from './ScrollToBottom';
|
||||||
import MultiMessage from './MultiMessage';
|
import MultiMessage from './MultiMessage';
|
||||||
|
|
@ -34,10 +35,11 @@ export default function Messages({ messages, messageTree }) {
|
||||||
};
|
};
|
||||||
}, [messages]);
|
}, [messages]);
|
||||||
|
|
||||||
const scrollToBottom = useCallback(() => {
|
const scrollToBottom = useCallback(throttle(() => {
|
||||||
|
console.log('scrollToBottom');
|
||||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||||
setShowScrollButton(false);
|
setShowScrollButton(false);
|
||||||
}, [messagesEndRef]);
|
}, 750), [messagesEndRef]);
|
||||||
|
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
const { scrollTop, scrollHeight, clientHeight } = scrollableRef.current;
|
const { scrollTop, scrollHeight, clientHeight } = scrollableRef.current;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue