Skip to content

Conversation

juri123123
Copy link
Contributor

@juri123123 juri123123 commented Oct 16, 2025

🌴 PR 요약

🌱 작업한 브랜치

🌱 PR Point

문제상황 -> 출석하고 뒤로가기를 했을 때 cell이 다시 그려지지 않아서 구독 취소가 되지 않음 (prepareForeReuse가 호출되는 시점은 cell이 다시 그려질 때라서 !!)

해결 -> viewDidDisappear에서 구독을 reset하는 로직 추가

📌 참고 사항

생략

📸 스크린샷

생략

📮 관련 이슈

@juri123123 juri123123 self-assigned this Oct 16, 2025
@juri123123 juri123123 added Fix 문제 해결, 코드 수정 주리🫐 labels Oct 16, 2025
@juri123123 juri123123 linked an issue Oct 16, 2025 that may be closed by this pull request
1 task
Copy link

height bot commented Oct 16, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

Copy link

coderabbitai bot commented Oct 16, 2025

Summary by CodeRabbit

릴리스 노트

  • Chores
    • 캘린더 셀의 구독 관리 체계를 개선하여 셀 라이프사이클 안정성을 강화했습니다.

Walkthrough

CalendarCardCVCresetSubscription() 메서드가 추가되어 기존 CancelBag을 취소하고 재초기화하며, 셀 등록 과정에서 셀의 취소백을 먼저 취소한 뒤에 셀을 구성하도록 순서를 변경했습니다.

Changes

Cohort / File(s) Change Summary
Calendar Card 구독 관리
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/Cells/Calendar/CalendarCardCVC.swift
resetSubscription() 메서드 추가 — 기존 CancelBag을 취소하고 새로 초기화하는 헬퍼 메서드 추가
셀 등록 시 구독 취소 순서 변경
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/CollectionView/Registration/HomeForMemberItemProvider.swift
셀 생성/등록 시 셀의 cancel bag을 먼저 취소한 뒤 configureCell 호출하도록 순서 변경

Sequence Diagram(s)

sequenceDiagram
    participant Provider as ItemProvider
    participant Cell as CalendarCardCVC

    Note over Provider,Cell #E8F6EF: 셀 생성/등록 흐름 (변경됨)
    Provider->>Cell: dequeue/register cell
    Provider->>Cell: call cancel existing subscriptions
    Cell->>Cell: resetSubscription()  -- cancels & reinitializes CancelBag
    Provider->>Cell: configureCell(item, userType)
    Cell-->>Provider: ready/display
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

size/S

Suggested reviewers

  • hye0njuoo
  • yungu0010

Poem

🐰 구독을 털고 다시 뛰네,
캔슬백을 쓱싹 정리했지요.
셀은 깔끔히 준비되고,
화면은 한결 가벼워졌네.
토끼가 축하의 당근을 드려요 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Linked Issues Check ❓ Inconclusive 연결된 이슈 #728의 목표는 "화면 중첩으로 인한 네비게이션 버그 수정"입니다. 그러나 raw_summary에서 중요한 문제가 식별됩니다: CalendarCardCVC에 resetSubscription() 메서드가 추가되었지만, "이 메서드는 이 diff에서 다른 곳에서 참조되지 않는다"고 명시되어 있습니다. PR 설명에서는 "viewDidDisappear에서 구독을 reset하는 로직 추가"라고 하지만, 실제 구현에서 이 메서드가 호출되고 있는지 확인이 필요합니다. 메서드 정의 자체만으로는 이슈를 해결할 수 없습니다. resetSubscription() 메서드가 실제로 viewDidDisappear에서 호출되고 있는지 확인이 필요합니다. 메서드 정의만으로는 구독 취소 문제를 해결할 수 없으므로, 메서드 호출 지점이 diff에 포함되어 있는지 검증해야 합니다. 또한 HomeForMemberItemProvider의 변경사항이 이 문제 해결에 어떤 역할을 하는지도 명확히 확인이 필요합니다.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed PR 제목 "[Fix] #728 - homeFeature 출석 버튼 탭 시 화면 중첩 네비게이션 버그 해결"은 변경사항의 주요 목적과 명확하게 일치합니다. 제목은 구체적으로 어떤 버그(화면 중첩 네비게이션)가 수정되었는지, 어느 부분(출석 버튼 탭)에서 발생했는지를 명시하고 있으며, 관련 이슈 번호도 포함하고 있습니다.
Out of Scope Changes Check ✅ Passed 제시된 변경사항은 모두 연결된 이슈 #728(화면 중첩 네비게이션 버그 수정)의 범위 내에 있습니다. CalendarCardCVC.swift의 resetSubscription() 메서드 추가와 HomeForMemberItemProvider.swift의 cancellation bag 취소 로직은 모두 구독이 취소되지 않는 문제를 해결하기 위한 의도된 변경사항입니다. 이슈와 무관한 변경이나 추가적인 기능 변경은 보이지 않습니다.
Description Check ✅ Passed PR 설명은 변경사항과 관련이 있으며 명확하게 작성되어 있습니다. 문제 상황(출석 후 뒤로가기 시 cell이 다시 그려지지 않아 구독이 취소되지 않음), 근본 원인(prepareForReuse가 호출되는 시점), 그리고 해결 방식(viewDidDisappear에서 구독 reset)을 체계적으로 설명하고 있습니다. 관련 이슈 #728도 명시되어 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#728-navigation-duplicate-bug

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81e3525 and eddad67.

📒 Files selected for processing (2)
  • SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/Cells/Calendar/CalendarCardCVC.swift (2 hunks)
  • SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/VC/HomeForMemberVC.swift (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/VC/HomeForMemberVC.swift (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/Cells/Calendar/CalendarCardCVC.swift (1)
  • resetSubscription (147-150)
🔇 Additional comments (2)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/Cells/Calendar/CalendarCardCVC.swift (1)

87-90: 구독 리셋 로직의 중앙화가 잘 되었습니다.

resetSubscription() 메서드로 구독 취소 로직을 추출하여 재사용 가능하게 만든 것은 좋은 리팩토링입니다. 이를 통해:

  • prepareForReuse()에서 재사용
  • 외부(HomeForMemberVC)에서도 호출 가능
  • 코드 중복 제거 및 유지보수성 향상

Also applies to: 147-150

SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/VC/HomeForMemberVC.swift (1)

387-391: prepareForReuse()에서 이미 구독이 해제됩니다
CalendarCardCVC의 prepareForReuse()가 cancelBag을 초기화하므로, HomeForMemberVC의 visibleCells 기반 resetCellSubscription() 메서드와 호출부는 중복이거나 불필요합니다. 사용하지 않는다면 해당 메서드와 호출 구문을 제거하세요.

Likely an incorrect or invalid review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/VC/HomeForMemberVC.swift (1)

387-391: 구현이 올바르며 문제를 효과적으로 해결합니다.

visibleCells 중 CalendarCardCVC 타입만 필터링하여 구독을 정리하는 로직이 정확하게 구현되었습니다. compactMap을 사용한 안전한 타입 캐스팅도 적절합니다.

선택적 개선사항:

  • 메서드명을 resetCellSubscriptions (복수형) 또는 resetVisibleCalendarCellSubscriptions로 변경하면 여러 셀을 처리한다는 의미가 더 명확해집니다.
  • 메서드에 간단한 주석을 추가하여 CalendarCardCVC만 대상으로 하는 이유를 설명하면 유지보수에 도움이 됩니다.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eddad67 and 17f6be1.

📒 Files selected for processing (1)
  • SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/VC/HomeForMemberVC.swift (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/VC/HomeForMemberVC.swift (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/Cells/Calendar/CalendarCardCVC.swift (1)
  • resetSubscription (147-150)

stopLatestPostAnimationLoop()
cancelTasks()
stopPopularPostsAnimationLoop()
resetCellSubscription()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

구독 정리 로직이 올바르게 구현되었습니다.

뷰 컨트롤러가 사라질 때 캘린더 셀의 구독을 정리하는 로직이 적절히 추가되었습니다. 이전 리뷰에서 지적된 메서드명 불일치 문제도 해결되었습니다.

참고: PR 설명에는 viewWillDisappear에서 구독을 reset한다고 명시되어 있으나, 실제 구현은 viewDidDisappear를 사용하고 있습니다. 두 메서드 모두 정리 작업에 적합하지만, 문서와 코드 간 일관성을 위해 PR 설명을 업데이트하는 것을 권장합니다.

🤖 Prompt for AI Agents
In
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/VC/HomeForMemberVC.swift
around line 91, the subscription reset is implemented in viewDidDisappear
(resetCellSubscription()) but the PR description states it runs in
viewWillDisappear; update the PR description to state that subscriptions are
reset in viewDidDisappear to keep docs consistent with code, or if you prefer
the cleanup to happen earlier change the implementation to call
resetCellSubscription() from viewWillDisappear instead and ensure method naming
and lifecycle choice are documented accordingly.

Copy link
Member

@yungu0010 yungu0010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오류 발견하고 고쳐주셔서 감사합니다!! 주리최고~~
리뷰 보시고 의견 남겨주시거나 반영해주세요~!

Comment on lines +147 to +150
func resetSubscription() {
self.cancelBag.cancel()
self.cancelBag = CancelBag()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수로 분리해주신 것 좋네요!

Comment on lines 387 to 392
private func resetCellSubscription() {
collectionView.visibleCells
.compactMap { $0 as? CalendarCardCVC }
.forEach { $0.resetSubscription() }
}
}
Copy link
Member

@yungu0010 yungu0010 Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기보단 HomeForMemberCellProvider의 메소드 내에서 cell.cancelBag.cancel()을 호출하는 것이 로직상 더 자연스러울 것 같아요.

🌱 제안 이유

CalendarCardCVCprepareForReuse()에서 구독을 초기화하고 있기 때문에, 스크롤되지 않는 상황에서는 구독이 해제되지 않는 것이 원인으로 보여요.

📌 의문점

여기서 한 가지 궁금했던 부분이 있었는데요. HomeForMemberVC에서 사용하는 다른 셀들(DefaultPostCVC, HomeDefaultHeaderView)도 똑같이 prepareForReuse()에서 구독을 초기화해주고 있는데, 왜 이 셀들은 스크롤하지 않아도 문제가 없었는지 의문이 들었습니다.

코드를 살펴보니 setItemsNeedUpdate()의 동작 차이가 원인이었던 것으로 보여요.

CalendarCVC의 경우

  1. setItemsNeedUpdate 호출마다 갱신
  2. 그 때마다 createCalendarCellRegistration() 클로저가 다시 실행
  3. 해당 메소드 내에서 새로운 구독이 cell.cancelBag에 추가
  4. 스크롤이 없는 경우 prepareForReuse()가 호출되지 않음
  5. cancelBag이 초기화되지 않은 채로 구독이 쌓이는 문제 발생

HomeDefaultHeaderView와 DefaultPostCVC

  1. setItemsNeedUpdate 에서 갱신하지 않음
  2. Provider의 메소드가 재호출되지 않음
  3. 구독이 그대로 유지
  4. 스크롤하지 않았을 때 구독 해제 되지 않는 것은 같음

📝 제안 방안

그래서 이 부분보다는 createCalendarCellRegistration() 메소드에서 cell.cancelBag.cancel()을 먼저 해주는 것이 더 적절하다고 생각합니다.

func createCalendarCellRegistration() -> CalendarCellRegistration {
    collectionView.createCellRegistration { [weak self] cell, _, item in
        guard let self else { return }
        
        // 새 구독 추가 전에 기존 구독 정리
        cell.cancelBag.cancel()
        
        // 이후 설정 진행...
    }
}

또한 VC에서 타입 캐스팅을 통해 특정 셀의 구독을 관리하는 것보다 셀을 설정하는 메소드에서 구독을 초기화하는 것이 흐름상으로도 더 자연스럽다고 생각해요!

저도 미처 발견하지 못했던 부분인데 덕분에 알고 갑니다👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우와 !! diffable data source를 사용해본 적이 없어서 cell 관리를 어떻게 해주는지 제대로 파악하지 못한 것 같네요 !!!!
덕분에 공부도 하고 많이 배워갑니다 !!!!!!

@dlwogus0128
Copy link
Contributor

구웃! 수고햇어요

@juri123123 juri123123 requested a review from yungu0010 October 22, 2025 06:12
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/CollectionView/Registration/HomeForMemberItemProvider.swift (1)

26-28: resetSubscription() 메서드를 사용하여 일관성 개선 필요

현재 구현은 cell.cancelBag.cancel()만 호출하지만, CalendarCardCVCprepareForReuse() 메서드(89-90줄)와 resetSubscription() 메서드(148-151줄)는 취소 후 CancelBag을 재초기화합니다. 일관성을 위해 다음과 같이 수정하세요:

-cell.cancelBag.cancel()
+cell.resetSubscription()

참고: 다른 셀들의 구독 취소 패턴

PopularPostCellRegistration, LatestPostCellRegistration, SurveyRegistrationcancelBag을 사용하지만 구독 취소를 하지 않습니다. 이들도 동일한 메모리 누수 위험이 있으나, 이는 별도 PR에서 처리하는 것을 추천합니다.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4dc412 and 87eb5d8.

📒 Files selected for processing (1)
  • SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/CollectionView/Registration/HomeForMemberItemProvider.swift (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/CollectionView/Registration/HomeForMemberItemProvider.swift (1)
SOPT-iOS/Projects/Features/HomeFeature/Sources/HomeScene/Cells/Calendar/CalendarCardCVC.swift (1)
  • configureCell (136-146)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix 문제 해결, 코드 수정 size/XS 주리🫐

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix] 화면 중첩 네비게이션 버그 수정

3 participants