Feat/#482 댓글 자동스크롤 기능 구현 - #483
Hidden character warning
Conversation
Walkthrough댓글과 답글 등록 성공 후 목록의 마지막 항목으로 자동 스크롤합니다. 등록 publisher의 Changes댓글 및 답글 자동 스크롤
빌드 버전 갱신
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant CommentPublisher as 댓글 등록 publisher
participant HistoryVC as CommonQuestHistoryViewController
participant ScrollView as 스크롤 뷰
CommentPublisher->>HistoryVC: 등록 성공 전달
HistoryVC->>HistoryVC: 마지막 댓글 확인 및 레이아웃 갱신
HistoryVC->>ScrollView: 마지막 댓글로 애니메이션 스크롤
sequenceDiagram
participant ReplyPublisher as 답글 등록 publisher
participant ReplyVC as CommonQuestReplyViewController
participant ScrollView as 스크롤 뷰
ReplyPublisher->>ReplyVC: 등록 성공 전달
ReplyVC->>ReplyVC: 마지막 답글 확인 및 레이아웃 갱신
ReplyVC->>ScrollView: 마지막 답글로 애니메이션 스크롤
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestHistoryViewController.swift`:
- Around line 316-321: 게시 성공 이벤트와 목록 snapshot 적용 순서를 보장하도록
CommonQuestHistoryViewController의 postComment/postReply 흐름을 수정하고,
CommonQuestHistoryViewController.swift 316-321 및
CommonQuestReplyViewController.swift 103-108의 성공 처리도 동일하게 반영하세요. fetchPublisher
완료와 dataSource.apply 호출 이후에 성공 이벤트가 발생하도록 연결하거나, 해당 이벤트 핸들러의 scrollToComment 호출을
snapshot 적용 완료 후로 이동해 새 댓글이 표시된 뒤 스크롤되게 하세요.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9439ea8f-942c-4eb5-9f09-2dd54c87e30d
📒 Files selected for processing (3)
ByeBoo-iOS/ByeBoo-iOS.xcodeproj/project.pbxprojByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestHistoryViewController.swiftByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestReplyViewController.swift
| .sink { [weak self] result in | ||
| guard let self else { return } | ||
| switch result { | ||
| case .success: | ||
| ByeBooLogger.debug("댓글 입력 성공") | ||
| self.scrollToComment() |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# 게시 성공과 목록 적용 순서를 확인합니다.
rg -n -C 12 \
'postCommentPublisher|postReplyPublisher|fetchCommonQuestDetailPublisher|fetchReplyListPublisher|applySnapshot|scrollToComment' \
--glob '*.swift'Repository: 36-APPJAM-HEARTZ/BYEBOO-iOS
Length of output: 165
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf 'Swift files matching controller names:\n'
fd -i 'CommonQuest(Reply|History)ViewController\.swift|CommonQuest.*Reply.*\.swift|CommonQuest.*History.*\.swift' ByeBoo-iOS/ByeBoo-iOS || true
printf '\nSearch identifiers with broader terms:\n'
rg -n -C 8 \
'scrollToComment|scrollToItem|apply\(Snapshot|snapshot|Append|Update|Insert|deleteItems|reloadData|func post|publisher|Subject|Publishers\.Merge|defer' \
ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest 2>/dev/null || true
printf '\nInspect candidate file outlines:\n'
for f in $(fd -i 'CommonQuest(Reply|History)ViewController\.swift' ByeBoo-iOS/ByeBoo-iOS); do
echo "--- $f ---"
wc -l "$f"
ast-grep outline "$f" --view compact || true
doneRepository: 36-APPJAM-HEARTZ/BYEBOO-iOS
Length of output: 50384
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
for f in \
'ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestHistoryViewController.swift' \
'ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestReplyViewController.swift' \
'ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewModel/CommonQuestHistoryViewModel.swift' \
'ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewModel/CommonQuestReplyViewModel.swift'
do
echo "--- $f ---"
wc -l "$f"
sed -n '1,240p' "$f"
done
echo '--- action enum candidates ---'
rg -n -C 4 'case (postComment|postReply|fetchQuestDetail|fetchReplyList|detail|replyList|FetchQuest|FetchReply)' \
ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestHistoryViewController.swift \
ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestReplyViewController.swift \
ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewModel/CommonQuestHistoryViewModel.swift \
ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewModel/CommonQuestReplyViewModel.swiftRepository: 36-APPJAM-HEARTZ/BYEBOO-iOS
Length of output: 31515
게시 성공 이벤트와 목록 snapshot 적용 순서를 맞춰주세요.
postComment() / postReply()는 목록을 먼저 업데이트하고 성공 이벤트를 보냅니다. 성공 핸들러는 이를 기다리지 않고 바로 scrollToComment()를 호출하므로, 게시 직후 목록에 새 댓글이 없으면 스크롤 대상이 없습니다. 게시 성공 이벤트는 목록 fetchPublisher + dataSource.apply 호출 이후에 생성되도록 변경하거나, 성공 처리기에서 snapshot 적용 완료 뒤에 scrollToComment()를 호출하도록 연결하세요.
📍 Affects 2 files
ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestHistoryViewController.swift#L316-L321(this comment)ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestReplyViewController.swift#L103-L108
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@ByeBoo-iOS/ByeBoo-iOS/Presentation/Feature/Quest/ViewController/CommonQuestHistoryViewController.swift`
around lines 316 - 321, 게시 성공 이벤트와 목록 snapshot 적용 순서를 보장하도록
CommonQuestHistoryViewController의 postComment/postReply 흐름을 수정하고,
CommonQuestHistoryViewController.swift 316-321 및
CommonQuestReplyViewController.swift 103-108의 성공 처리도 동일하게 반영하세요. fetchPublisher
완료와 dataSource.apply 호출 이후에 성공 이벤트가 발생하도록 연결하거나, 해당 이벤트 핸들러의 scrollToComment 호출을
snapshot 적용 완료 후로 이동해 새 댓글이 표시된 뒤 스크롤되게 하세요.
🔗 연결된 이슈
📄 작업 내용
💻 주요 코드 설명
답글 자동 스크롤
답글 작성이 완료되는 시점에서 스크롤 함수를 호출합니다.
마지막 인덱스를 구해서 UITableView의 함수 scrollToRow의 파라미터로 사용합니다.
댓글 자동 스크롤
ReplyVC에서는 일반 UITableView를 사용하는데, HistoryVC에서는 UITableView를 커스텀한 Self-sizing TableView를 사용합니다.
이때 tableview 자체의 scroll이 꺼져있기 때문에 scrollToRow를 사용할 수 없었습니다.
이 변환 없이 scrollRect를 하게 되면 rect의 top으로 스크롤 되어 댓글 내용이 다 보이지 않게 되는 문제가 있었습니다.
그래서 scrollView의 height에서 rect의 y가 어디서 시작하는지를 빼서 마지막 댓글의 top부터 스크롤뷰 하단까지의 높이가 rect height가 되도록 보정을 거쳤습니다.
Summary by CodeRabbit
개선 사항
기타