Skip to content

Commit

Permalink
SK-93 fixed message pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr1414 committed Jun 11, 2024
1 parent 68e7d15 commit 7056fb8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/hub/elements/MessagesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import { getConverastionById, upsertChat } from "@store/values/Conversations";
import { selectCurrentUser } from "@store/values/CurrentUser";
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useLocation } from "react-router-dom";

export default function MessagesList({ scrollRef }) {
const dispatch = useDispatch();
const location = useLocation();

const messages = useSelector(selectActiveConversationMessages);
const participants = useSelector(selectParticipantsEntities);
Expand Down Expand Up @@ -46,9 +48,7 @@ export default function MessagesList({ scrollRef }) {
}
};

useEffect(() => {
updateParticipantsFromMessages();
}, []);
useEffect(() => updateParticipantsFromMessages(), []);

const needToGetMoreMessage = useRef(true);
const lastMessageRef = useCallback(() => {
Expand Down Expand Up @@ -139,8 +139,9 @@ export default function MessagesList({ scrollRef }) {
behavior: "smooth",
block: "end",
});
needToGetMoreMessage.current = true;
}, 300);
}, []);
}, [location]);

return (
<InfiniteScroll
Expand Down

0 comments on commit 7056fb8

Please sign in to comment.