Skip to content

Commit

Permalink
Fixed loading feed
Browse files Browse the repository at this point in the history
  • Loading branch information
macedonga committed Oct 28, 2024
1 parent 8ff5cbc commit fb841e6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pages/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default function Feed(props) {
const [ShouldShowDonationBox, setShouldShowDonationBox] = useState(false);
const [ShowArchiverBox, setShowArchiverBox] = useState(false);
const [FriendsPosts, setFriendsPosts] = useState([]);
const [FriendsPostsIndex, setFriendsPostsIndex] = useState(1);
const [Data, setData] = useState();

const handleScroll = () => {
Expand All @@ -48,11 +47,11 @@ export default function Feed(props) {

if (scrollPosition >= pageHeight - threshold) {
setData(o => {
const posts = o?.friendsPosts?.slice(0, (FriendsPostsIndex + 1) * 5);
const lastIndex = o?.friendsPosts?.length;
const posts = o?.friendsPosts?.slice(0, lastIndex + 1);

if (posts.length !== FriendsPosts.length) {
setFriendsPosts(posts);
setFriendsPostsIndex(FriendsPostsIndex + 1);
}

return o;
Expand Down

0 comments on commit fb841e6

Please sign in to comment.