-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FE] refactor: MSW 환경에서 무한 스크롤 API 응답을 서버와 통일하고, 빈 리뷰에 대한 옵저버 로직 개선 #754
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
798c037
refactor: useInfiniteScroll에서 isLastPage 제거
soosoo22 45fe30e
refactor: 목 핸들러에서 마지막 리뷰 id를 반환하는 로직 개선
soosoo22 6aae5ee
refactor: 리뷰가 더이상 없을 경우, hasNextPage를 false로 반환
soosoo22 63c09c3
refactor: 목 데이터에서 lastReviewId 값 수정
soosoo22 7b562ac
refactor: isLastPage를 사용한 fetchNextPage 호출
soosoo22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
서버에서 내려주는 isLastPage를 사용하지 않은 이유가 있나요?
리뷰 데이터가 많아질 수록 배열 시간 복잡도가 올라가서 isLastPage를 사용하지 않고 배열을 순회해야하는 것에 의문이 들어서요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
서버에서 isLastPage를 true 주고 다시 한번 api 요청을 해서, 불필요한 api 요청이 추가로 가는 것이 아닌가 싶네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isLastPage를 사용해서 옵저버를 해제하면 무한스크롤로 받은 리뷰를 다 확인했을 때 살짝 올라갔다가 내려가면 다시 첫 리뷰를 불러오면서 리뷰가 무한 증식이 되어버립니다... 제가 보기엔 isLastReviewId가 0이면 첫 리뷰를 불러오고 있는데 거기서 문제가 있는게 아닌가... 싶네요..
⭐️해결 완료⭐️
콘솔로 isLastPage를 찍어서 확인해보니 false만을 넘겨주고 있더라고요. isLastPage가 false로만 넘어가던 이유는, 데이터를 받는 과정에서 가장 첫 번째 페이지의 isLastPage 값을 사용하고 있었어요. 실제로는 마지막으로 받은 페이지의 isLastPage 값을 넘겨줘야 했던 상황이었는데 말이죠...
수정한 방식인
data.pages[data.pages.length - 1].isLastPage;
를 넘겨주는 방식으로 수정했습니다. 마지막 페이지의 데이터를 기준으로 isLastPage 값을 설정해주어서, 올바르게 동작하네요!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞습니다... 이 부분은 수정해야 겠네요.
⭐️ 해결 완료 ⭐️
isLastPage를 활용해서 true를 받으면 바로 옵저버에 fetchNextPage 함수가 호출되지 않게 수정했습니다. => 추가 api 요청이 가지 않습니다.