Skip to content

Commit

Permalink
fix: when the scroll touches the last message it does fluctuate
Browse files Browse the repository at this point in the history
  • Loading branch information
pritipsingh committed Mar 27, 2024
1 parent 8d961bd commit 1d0df7b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,5 @@
"ts-jest": "27.1.4",
"ts-node": "9.1.1",
"typescript": "5.0.2"
},
"packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const ChatSupportTest = () => {
<SupportChat

signer={librarySigner}
supportAddress="0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666"
supportAddress="4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68"
env={env}
greetingMsg="How can i help you?"
theme={lightTheme}
Expand Down
5 changes: 3 additions & 2 deletions packages/uiweb/src/lib/components/supportChat/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Modal: React.FC = () => {
const [lastThreadHashFetched, setLastThreadHashFetched] = useState<
string | null
>(null);
const [wasLastListPresent, setWasLastListPresent] = useState<boolean>(false);
const [wasLastListPresent, setWasLastListPresent] = useState<boolean>(true);
const { supportAddress, user, env, account, signer, greetingMsg, theme } =
useContext<any>(SupportChatPropsContext);
const {
Expand Down Expand Up @@ -61,6 +61,7 @@ export const Modal: React.FC = () => {
icon: <HandWaveSvg fill={theme.btnColorPrimary} />,
};
const onScroll = async () => {
if (!wasLastListPresent) return;
if (listInnerRef.current) {
const { scrollTop } = listInnerRef.current;
if (scrollTop === 0) {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/uiweb/src/lib/helpers/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

};
Expand Down

0 comments on commit 1d0df7b

Please sign in to comment.