fix: update messages
This commit is contained in:
parent
e157651e6a
commit
9f280de2fe
@ -4,7 +4,6 @@ import {
|
||||
IconButton,
|
||||
InputAdornment,
|
||||
InputBase,
|
||||
InputLabel,
|
||||
SxProps,
|
||||
Theme,
|
||||
Typography,
|
||||
@ -21,8 +20,7 @@ import ChatMessage from "./ChatMessage";
|
||||
import ChatVideo from "./ChatVideo";
|
||||
import SendIcon from "@icons/SendIcon";
|
||||
import UserCircleIcon from "./UserCircleIcon";
|
||||
import { throttle, getAuthToken } from "@frontend/kitui";
|
||||
import { useEventListener } from "@frontend/kitui";
|
||||
import { throttle } from "@frontend/kitui";
|
||||
import ArrowLeft from "@icons/questionsPage/arrowLeft";
|
||||
import { useUserStore } from "@root/user";
|
||||
import AttachFileIcon from "@mui/icons-material/AttachFile";
|
||||
@ -35,6 +33,8 @@ import {
|
||||
} from "@utils/checkAcceptableMediaType";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
|
||||
import type { WheelEvent, TouchEvent } from "react";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
sx?: SxProps<Theme>;
|
||||
@ -110,7 +110,6 @@ export default function Chat({
|
||||
}, 200),
|
||||
[fetchState],
|
||||
);
|
||||
useEventListener("scroll", throttledScrollHandler, chatBoxRef);
|
||||
|
||||
useEffect(() => {
|
||||
if (chatBoxRef.current && chatBoxRef.current.scrollTop < 1)
|
||||
@ -128,6 +127,15 @@ export default function Chat({
|
||||
},
|
||||
[lastMessageId],
|
||||
);
|
||||
|
||||
const loadNewMessages = (
|
||||
event: WheelEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>,
|
||||
) => {
|
||||
event.stopPropagation();
|
||||
|
||||
throttledScrollHandler();
|
||||
};
|
||||
|
||||
function scrollToBottom(behavior?: ScrollBehavior) {
|
||||
if (!chatBoxRef.current) return;
|
||||
|
||||
@ -209,6 +217,8 @@ export default function Chat({
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
onWheel={loadNewMessages}
|
||||
onTouchMove={loadNewMessages}
|
||||
ref={chatBoxRef}
|
||||
sx={{
|
||||
display: "flex",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user