From 1d0df7b08712b2a082f4420b74c0ae75a05551e2 Mon Sep 17 00:00:00 2001 From: Pritipriya Singh Date: Wed, 27 Mar 2024 16:46:28 +0530 Subject: [PATCH] fix: when the scroll touches the last message it does fluctuate --- package.json | 3 +-- .../examples/sdk-frontend-react/src/app/ChatSupportTest.tsx | 2 +- packages/uiweb/src/lib/components/supportChat/Modal.tsx | 5 +++-- packages/uiweb/src/lib/helpers/chat/chat.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 662ad8275..2d6720e6e 100644 --- a/package.json +++ b/package.json @@ -127,6 +127,5 @@ "ts-jest": "27.1.4", "ts-node": "9.1.1", "typescript": "5.0.2" - }, - "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" + } } diff --git a/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx b/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx index 276eadef8..905cd14ee 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx @@ -35,7 +35,7 @@ export const ChatSupportTest = () => { { const [lastThreadHashFetched, setLastThreadHashFetched] = useState< string | null >(null); - const [wasLastListPresent, setWasLastListPresent] = useState(false); + const [wasLastListPresent, setWasLastListPresent] = useState(true); const { supportAddress, user, env, account, signer, greetingMsg, theme } = useContext(SupportChatPropsContext); const { @@ -61,6 +61,7 @@ export const Modal: React.FC = () => { icon: , }; const onScroll = async () => { + if (!wasLastListPresent) return; if (listInnerRef.current) { const { scrollTop } = listInnerRef.current; if (scrollTop === 0) { @@ -85,7 +86,7 @@ export const Modal: React.FC = () => { const getChatCall = async () => { if (!connectedUser) return; - if (wasLastListPresent && !lastThreadHashFetched) return; + if (!wasLastListPresent && !lastThreadHashFetched) return; setLoading(true); const { chatsResponse, lastThreadHash, lastListPresent } = await getChats({ account, diff --git a/packages/uiweb/src/lib/helpers/chat/chat.ts b/packages/uiweb/src/lib/helpers/chat/chat.ts index c9d39c143..0c013a8c6 100644 --- a/packages/uiweb/src/lib/helpers/chat/chat.ts +++ b/packages/uiweb/src/lib/helpers/chat/chat.ts @@ -83,7 +83,7 @@ export const getChats = async ( ); const lastThreadHash = chats[chats.length - 1]?.link; - const lastListPresent = chats.length > 0 ? true : false; + const lastListPresent = chats.length < limit ? false : true; return { chatsResponse: chats, lastThreadHash, lastListPresent }; };