Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 중복 게시글 로드 현상 수정, 빠르게 스크롤을 내릴 시 중복요청 해결 #66

Closed
wants to merge 1 commit into from

Conversation

Andrevile
Copy link
Owner

📌 개요

👩‍💻 작업사항

  • 몽구스의 limit을 5개로 설정하여 5개만 로드하도록 수정하고, 로드요청을
    할 때마다 마지막 게시글 보다 적은 _id 값을 가진 게시글을 로드하도록
    수정
  • 중복요청과 데이터의 마지막을 구분하기 위해서, loadPostsLoading,
    hasMorePosts 를 사용.(!loadPostsLoading && hasMorePosts)
    pending 중에서는 loadPostsLoading = true이고
    더 불러올 게시글이 있을 때는 전에 불러온 게시글이 꽉 차 있는
    상태이므로 hasMorePosts = action.payload.length === 5 = true;
    만일 더 불러올 게시글이 없는 경우에는 hasMorePosts =
    action.payload.length < 5 = false 이거나
    새로 불러온 게시글이 없으므로 로드 못함
  • 위와같이 처리하더라도, 스크롤을 redux state가 변하기 전에 내리게 되면
    중복 이벤트가 발생하기 때문에 쓰로틀링을 사용하여 처리

✅ 변경로직

- 몽구스의 limit을 5개로 설정하여 5개만 로드하도록 수정하고, 로드요청을
  할 때마다 마지막 게시글 보다 적은 _id 값을 가진 게시글을 로드하도록
  수정
- 중복요청과 데이터의 마지막을 구분하기 위해서, loadPostsLoading,
  hasMorePosts 를 사용.(!loadPostsLoading && hasMorePosts)
  pending 중에서는 loadPostsLoading = true이고
  더 불러올 게시글이 있을 때는 전에 불러온 게시글이 꽉 차 있는
  상태이므로 hasMorePosts = action.payload.length === 5 = true;
  만일 더 불러올 게시글이 없는 경우에는 hasMorePosts =
  action.payload.length < 5 = false 이거나
  새로 불러온 게시글이 없으므로 로드 못함
 - 위와같이 처리하더라도, 스크롤을 redux state가 변하기 전에 내리게 되면
  중복 이벤트가 발생하기 때문에 쓰로틀링을 사용하여 처리
@Andrevile Andrevile closed this Mar 18, 2022
@Andrevile Andrevile reopened this Mar 18, 2022
@Andrevile Andrevile closed this Mar 18, 2022
@Andrevile Andrevile deleted the fix/infinite branch March 18, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant