fix fetch on scroll
This commit is contained in:
parent
9b55c9731b
commit
e5f679fd96
@ -44,6 +44,7 @@ export default function Chat({ sx }: Props) {
|
||||
}).then(result => {
|
||||
console.log("GetMessagesResponse", result);
|
||||
if (result?.length > 0) {
|
||||
if (chatBoxRef.current && chatBoxRef.current.scrollTop < 1) chatBoxRef.current.scrollTop = 1;
|
||||
addOrUpdateUnauthMessages(result);
|
||||
setUnauthTicketFetchState("idle");
|
||||
} else setUnauthTicketFetchState("all fetched");
|
||||
@ -81,7 +82,6 @@ export default function Chat({ sx }: Props) {
|
||||
|
||||
return () => {
|
||||
unsubscribe();
|
||||
// clearUnauthTicketState();
|
||||
setUnauthIsPreventAutoscroll(false);
|
||||
};
|
||||
}, [sessionData]);
|
||||
@ -98,7 +98,6 @@ export default function Chat({ sx }: Props) {
|
||||
if (messagesFetchStateRef.current !== "idle") return;
|
||||
|
||||
if (chatBox.scrollTop < chatBox.clientHeight) {
|
||||
if (chatBox.scrollTop < 1) chatBox.scrollTop = 1;
|
||||
incrementUnauthMessageApiPage();
|
||||
}
|
||||
};
|
||||
|
@ -47,6 +47,7 @@ export default function SupportChat() {
|
||||
}).then(result => {
|
||||
console.log("GetMessagesResponse", result);
|
||||
if (result?.length > 0) {
|
||||
if (chatBoxRef.current && chatBoxRef.current.scrollTop < 1) chatBoxRef.current.scrollTop = 1;
|
||||
addOrUpdateMessages(result);
|
||||
setMessageFetchState("idle");
|
||||
} else setMessageFetchState("all fetched");
|
||||
@ -99,7 +100,6 @@ export default function SupportChat() {
|
||||
if (messagesFetchStateRef.current !== "idle") return;
|
||||
|
||||
if (chatBox.scrollTop < chatBox.clientHeight) {
|
||||
if (chatBox.scrollTop < 1) chatBox.scrollTop = 1;
|
||||
incrementMessageApiPage();
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user