Skip to content

Conversation

@JinUng41
Copy link
Collaborator

@JinUng41 JinUng41 commented Mar 31, 2025

👻 PULL REQUEST

📄 작업 내용

  • 소식 탭의 기능적 또는 UI 오류를 수정하였습니다.
  • UseCase를 구현하고 적용하였습니다.
  • 레포지토리를 의존성 등록하였습니다.
    • 하지만 아직 임시 버튼이 있기에 동작은 MockUseCase로 동작합니다.
구현 내용 IPhone 13 mini
경기 스케줄
순위
뉴스
공지사항
상세 페이지

💻 주요 코드 설명

📍 버튼 타이틀 색 하이라이팅

  • 버튼 타이틀 중 일부를 색 하이라이팅 (별개의 색) 을 적용하였습니다.
  • 결과는 순위 이미지를 참고해 주세요.
특정 글자 색 하이라이팅
private let submitButton = WableButton(style: .black).then {
    var config = $0.configuration
    let fullText = NSMutableAttributedString(Constant.submitButtonTitle.pretendardString(with: .body3))
    if let range = Constant.submitButtonTitle.range(of: "의견 남기러 가기") {
        fullText.addAttributes(
            [.foregroundColor: UIColor.sky50],
            range: NSRange(range, in: Constant.submitButtonTitle)
        )
    }
    
    config?.attributedTitle = AttributedString(fullText)
    $0.configuration = config
}

📍 레포지토리 의존성 등록 및 주입

  • DIContainer에 InformationRepositoryImpl을 등록하고, 추후 @Injected를 통해 간편하게 주입될 수 있도록 하였습니다.
레포지토리 의존성 등록 및 주입
extension AppDelegate {
    var diContainer: AppDIContainer { AppDIContainer.shared }
    
    func injectDependency() {
        diContainer.register(for: InformationRepository.self, object: InformationRepositoryImpl())
    }
}
final class OverviewUseCaseImpl: OverviewUseCase {
    @Injected private var repository: InformationRepository // @Injected를 이용한 주입
    
    // 생성자 필요 X
}

👀 기타 더 이야기해볼 점

📍 pretendardString 리턴 타입

  • pretendardString 메서드의 반환 타입을 NSAttributedString에서 NSMutableAttributedString으로 변경하는 것은 어떨까요?
  • NSMutableAttributedStringNSAttributedString을 상속하므로 현재 코드에서 사용 중인 곳에서 호환성 문제 없이 대체할 수 있습니다.
  • 또한 NSAttributedString은 생성 후 속성을 변경할 수 없는 반면, NSMutableAttributedString은 생성 후에도 속성을 동적으로 수정할 수 있어 더 유연하게 사용할 수 있습니다. 이렇게 변경하면 이 메서드를 사용하는 코드에서 필요한 경우 추가 속성을 설정하거나 기존 속성을 수정할 수 있게 됩니다.

변경된 pretendardString을 사용할 경우

private let submitButton = WableButton(style: .black).then {
    var config = $0.configuration
    // 이제 직접 NSMutableAttributedString을 반환받으므로 변환 과정이 필요 없음
    let fullText = Constant.submitButtonTitle.pretendardString(with: .body3)
    if let range = fullText.string.range(of: "의견 남기러 가기") {
        fullText.addAttributes(
            [.foregroundColor: UIColor.sky50],
            range: NSRange(range, in: Constant.submitButtonTitle)
        )
    }
    
    config?.attributedTitle = AttributedString(fullText)
    $0.configuration = config
}
  • 기존에는 NSAttributedStringNSMutableAttributedString으로 다시 변환하는 과정이 필요했지만, 메서드가 직접 NSMutableAttributedString을 반환하므로 이 변환 단계가 필요 없어집니다.

📍 Mock 객체와 실제 사용되는 객체 스위칭을 위한 팩토리 패턴 도입

  • 지금 당장에 의논하기에는 다소 어려움이 있으나, 추후 Mock 객체와 실제 사용되는 객체의 스위칭을 위한 팩토리 패턴이 필요해 보입니다.

🔗 연결된 이슈

Summary by CodeRabbit

  • New Features

    • Introduced a new structured approach for retrieving game, news, ranks, and notices to enhance overall data flow.
  • Improvements

    • Enhanced dependency injection to reliably register required services for smoother app operation.
    • Updated initialization and layout for announcement details, game schedule empty states, and collection view items to improve UI consistency and responsiveness.
  • Refactors

    • Transitioned from an outdated repository pattern to a use-case driven architecture for better maintainability and performance.
    • Removed unused components to streamline the codebase and improve clarity.

@JinUng41 JinUng41 added 🛠️ fix 기능적 버그나 오류 해결 시 사용 🍻 진웅 술 한잔 가온나~ labels Mar 31, 2025
@JinUng41 JinUng41 added this to the 리팩토링 마감 milestone Mar 31, 2025
@JinUng41 JinUng41 requested a review from youz2me March 31, 2025 12:35
@JinUng41 JinUng41 self-assigned this Mar 31, 2025
@coderabbitai
Copy link

coderabbitai bot commented Mar 31, 2025

Walkthrough

The pull request removes the GameScheduleEmptyView and its references from the project configuration, updates dependency injection by introducing the OverviewUseCase protocol and refactoring various view models to use it, and adjusts data mapping to handle optional image URLs. Additionally, it removes the mock implementation from the repository layer and refines several UI components and layout constraints across news, notice, and game schedule screens.

Changes

File(s) Change Summary
Wable-iOS.xcodeproj/project.pbxproj, Wable-iOS/Presentation/Overview/GameSchedule/View/Subview/GameScheduleEmptyView.swift Removed references to and the file for GameScheduleEmptyView from project configuration and groups.
Wable-iOS/App/AppDelegate+InjectDependency.swift, Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift, Wable-iOS/Presentation/Overview/GameSchedule/ViewModel/GameScheduleViewModel.swift, Wable-iOS/Presentation/Overview/News/ViewModel/NewsViewModel.swift, Wable-iOS/Presentation/Overview/Notice/ViewModel/NoticeViewModel.swift, Wable-iOS/Presentation/Overview/Rank/ViewModel/RankViewModel.swift, Wable-iOS/Presentation/Overview/Page/View/OverviewPageViewController.swift Updated dependency injection; introduced the OverviewUseCase to replace the repository pattern and refactored view models to use this new use case interface.
Wable-iOS/Data/Mapper/InformationMapper.swift, Wable-iOS/Infra/Network/DTO/Response/Information/FetchNews.swift, Wable-iOS/Infra/Network/DTO/Response/Information/FetchNotices.swift Modified URL creation to use nil-coalescing and updated DTO properties to optionals for handling absent image URLs.
Wable-iOS/Data/RepositoryImpl/InformationRepositoryImpl.swift Removed the MockInformationRepositoryImpl struct and its associated mock methods.
Wable-iOS/Presentation/Overview/Detail/View/AnnouncementDetailViewController.swift, Wable-iOS/Presentation/Overview/Detail/View/Subview/AnnouncementDetailView.swift, Wable-iOS/Presentation/Overview/GameSchedule/View/GameScheduleListViewController.swift, Wable-iOS/Presentation/Overview/News/View/NewsViewController.swift, Wable-iOS/Presentation/Overview/Notice/View/Cell/NoticeCell.swift, Wable-iOS/Presentation/Overview/Notice/View/NoticeViewController.swift, Wable-iOS/Presentation/Overview/Rank/View/RankListViewController.swift Adjusted UI layouts, constraints, and initialization; introduced custom initializers and refined image loading handling, layout anchors, and attributed text configurations.

Sequence Diagram(s)

sequenceDiagram
    participant VC as ViewController
    participant VM as ViewModel
    participant UC as OverviewUseCase
    VC->>VM: Trigger view load/refresh event
    VM->>UC: Call data fetch methods (e.g., fetchGameCategory, fetchNews)
    UC-->>VM: Return data (or error) via publisher
    VM->>VC: Update UI with fetched data
Loading

Assessment against linked issues

Objective Addressed Explanation
소식 탭 내 엠티뷰 초기 isHidden 설정 삭제 (#154)
소식 탭, 상세뷰의 UI 수정 (#154)
소식 탭에 UseCase 적용 (#154)

Suggested reviewers

  • youz2me

Hippity-hop, I scurry along,
Code changes made so nothing's wrong.
UseCase now leads the data race,
UI refined with agile grace.
With every hop and joyful cheer,
This rabbit sings our update clear! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@JinUng41 JinUng41 moved this to In Review in Wable-iOS Mar 31, 2025
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 (9)
Wable-iOS/Presentation/Overview/Rank/View/RankListViewController.swift (1)

44-56: Good implementation of highlighted text in button title

The implementation cleverly uses NSMutableAttributedString to highlight the "의견 남기러 가기" portion of the button text with a sky blue color, which likely improves UI clarity and visual hierarchy.

One potential improvement to consider would be extracting this text styling logic into a reusable helper method if this pattern is used elsewhere in the codebase.

 private let submitButton = WableButton(style: .black).then {
     var config = $0.configuration
-    let fullText = NSMutableAttributedString(Constant.submitButtonTitle.pretendardString(with: .body3))
-    if let range = Constant.submitButtonTitle.range(of: "의견 남기러 가기") {
-        fullText.addAttributes(
-            [.foregroundColor: UIColor.sky50],
-            range: NSRange(range, in: Constant.submitButtonTitle)
-        )
-    }
-    
-    config?.attributedTitle = AttributedString(fullText)
+    config?.attributedTitle = AttributedString(createHighlightedText(
+        fullText: Constant.submitButtonTitle, 
+        highlightedPart: "의견 남기러 가기", 
+        highlightColor: .sky50
+    ))
     $0.configuration = config
 }

// Add this helper method to the extension
private func createHighlightedText(fullText: String, highlightedPart: String, highlightColor: UIColor) -> NSAttributedString {
    let attributedString = NSMutableAttributedString(fullText.pretendardString(with: .body3))
    if let range = fullText.range(of: highlightedPart) {
        attributedString.addAttributes(
            [.foregroundColor: highlightColor],
            range: NSRange(range, in: fullText)
        )
    }
    return attributedString
}
Wable-iOS/Presentation/Overview/Page/View/OverviewPageViewController.swift (2)

141-144: Remove TODO comment in production code.

The TODO comment indicates that it should be removed in the future. Consider removing it now or add more context about when it should be removed.

-        // TODO: 추후 주석 삭제 요망
-        
         let useCase = MockOverviewUseCaseImpl()
//        let useCase = OverviewUseCaseImpl()
🧰 Tools
🪛 SwiftLint (0.57.0)

[Warning] 141-141: TODOs should be resolved (추후 주석 삭제 요망)

(todo)


143-144: Consider implementing factory pattern for switching between mock and real implementations.

Currently, you're using the mock implementation with a commented out real implementation. As mentioned in your PR description, a factory pattern would be beneficial here to easily switch between mock and real implementations.

-        let useCase = MockOverviewUseCaseImpl()
-//        let useCase = OverviewUseCaseImpl()
+        let useCase: OverviewUseCase = AppEnvironment.isTestMode ? 
+            MockOverviewUseCaseImpl() : 
+            OverviewUseCaseImpl()
Wable-iOS/Presentation/Overview/GameSchedule/ViewModel/GameScheduleViewModel.swift (1)

33-38: Consider enhanced error handling for the replaced calls.
Using replaceError(with: "") or replaceError(with: []) helps avoid crashes, but it also swallows the error. If applicable, consider adding user-visible error handling or logging to provide better feedback.

Wable-iOS/Presentation/Overview/News/ViewModel/NewsViewModel.swift (1)

40-51: Refresh pipeline logic is coherent.
Merging viewDidLoad and viewDidRefresh, setting loading states, and then fetching the news from the useCase is a clean approach. Consider verifying whether ignoring fetch errors completely is acceptable or if a fallback UI state is required.

Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (4)

13-20: Recommend brief documentation for protocol methods.
Adding concise docstrings for each method in OverviewUseCase can clarify their behavior, parameters, and error contracts for future maintainers.


49-49: Address TODO comment.
The TODO indicates a pending comparison between server data and local storage. Consider resolving this soon to ensure the checkNewAnnouncements() method accurately reflects production requirements.

Would you like me to propose a possible approach for storing and comparing local data?

🧰 Tools
🪛 SwiftLint (0.57.0)

[Warning] 49-49: TODOs should be resolved (서버에서 받아오는 값과 로컬에 저장한 값을 비교 후, ...)

(todo)


66-70: Mock: Consider making "2025 LCK SPRING" configurable.
Hardcoding the season's name is fine for temporary usage, but introducing a parameter or config can make tests more flexible in the future.


102-129: Review the .just([]) return in createMockGameSchedules().
It looks like actual mock data is generated but ultimately not returned. Returning an empty array might limit the realism of your mock. If this is intentional, please disregard. Otherwise, consider returning mockGameSchedules for more accurate test scenarios.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d084f9 and de41963.

📒 Files selected for processing (20)
  • Wable-iOS.xcodeproj/project.pbxproj (0 hunks)
  • Wable-iOS/App/AppDelegate+InjectDependency.swift (1 hunks)
  • Wable-iOS/Data/Mapper/InformationMapper.swift (2 hunks)
  • Wable-iOS/Data/RepositoryImpl/InformationRepositoryImpl.swift (0 hunks)
  • Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (1 hunks)
  • Wable-iOS/Infra/Network/DTO/Response/Information/FetchNews.swift (1 hunks)
  • Wable-iOS/Infra/Network/DTO/Response/Information/FetchNotices.swift (1 hunks)
  • Wable-iOS/Presentation/Overview/Detail/View/AnnouncementDetailViewController.swift (2 hunks)
  • Wable-iOS/Presentation/Overview/Detail/View/Subview/AnnouncementDetailView.swift (2 hunks)
  • Wable-iOS/Presentation/Overview/GameSchedule/View/GameScheduleListViewController.swift (4 hunks)
  • Wable-iOS/Presentation/Overview/GameSchedule/View/Subview/GameScheduleEmptyView.swift (0 hunks)
  • Wable-iOS/Presentation/Overview/GameSchedule/ViewModel/GameScheduleViewModel.swift (2 hunks)
  • Wable-iOS/Presentation/Overview/News/View/NewsViewController.swift (1 hunks)
  • Wable-iOS/Presentation/Overview/News/ViewModel/NewsViewModel.swift (4 hunks)
  • Wable-iOS/Presentation/Overview/Notice/View/Cell/NoticeCell.swift (1 hunks)
  • Wable-iOS/Presentation/Overview/Notice/View/NoticeViewController.swift (1 hunks)
  • Wable-iOS/Presentation/Overview/Notice/ViewModel/NoticeViewModel.swift (4 hunks)
  • Wable-iOS/Presentation/Overview/Page/View/OverviewPageViewController.swift (1 hunks)
  • Wable-iOS/Presentation/Overview/Rank/View/RankListViewController.swift (2 hunks)
  • Wable-iOS/Presentation/Overview/Rank/ViewModel/RankViewModel.swift (2 hunks)
💤 Files with no reviewable changes (3)
  • Wable-iOS/Presentation/Overview/GameSchedule/View/Subview/GameScheduleEmptyView.swift
  • Wable-iOS/Data/RepositoryImpl/InformationRepositoryImpl.swift
  • Wable-iOS.xcodeproj/project.pbxproj
🧰 Additional context used
🧬 Code Definitions (5)
Wable-iOS/Presentation/Overview/GameSchedule/ViewModel/GameScheduleViewModel.swift (1)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (4)
  • fetchGameCategory (27-29)
  • fetchGameCategory (66-70)
  • fetchGameSchedules (31-33)
  • fetchGameSchedules (72-76)
Wable-iOS/Presentation/Overview/Rank/ViewModel/RankViewModel.swift (1)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (4)
  • fetchGameCategory (27-29)
  • fetchGameCategory (66-70)
  • fetchTeamRanks (35-37)
  • fetchTeamRanks (78-82)
Wable-iOS/Presentation/Overview/News/ViewModel/NewsViewModel.swift (3)
Wable-iOS/Data/RepositoryImpl/InformationRepositoryImpl.swift (1)
  • fetchNews (54-61)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (2)
  • fetchNews (39-41)
  • fetchNews (84-88)
Wable-iOS/Presentation/Overview/Notice/ViewModel/NoticeViewModel.swift (1)
  • isLastPage (107-109)
Wable-iOS/Presentation/Overview/Notice/ViewModel/NoticeViewModel.swift (2)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (2)
  • fetchNotices (43-45)
  • fetchNotices (90-94)
Wable-iOS/Presentation/Overview/News/ViewModel/NewsViewModel.swift (1)
  • isLastPage (109-111)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (3)
Wable-iOS/Data/RepositoryImpl/InformationRepositoryImpl.swift (5)
  • fetchGameCategory (27-34)
  • fetchGameSchedules (18-25)
  • fetchTeamRanks (36-43)
  • fetchNews (54-61)
  • fetchNotice (63-70)
Wable-iOS/Presentation/Overview/News/ViewModel/NewsViewModel.swift (1)
  • fetchNews (100-107)
Wable-iOS/Presentation/Overview/Notice/ViewModel/NoticeViewModel.swift (1)
  • fetchNotices (98-105)
🪛 SwiftLint (0.57.0)
Wable-iOS/Presentation/Overview/Page/View/OverviewPageViewController.swift

[Warning] 141-141: TODOs should be resolved (추후 주석 삭제 요망)

(todo)

Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift

[Warning] 49-49: TODOs should be resolved (서버에서 받아오는 값과 로컬에 저장한 값을 비교 후, ...)

(todo)

🔇 Additional comments (39)
Wable-iOS/Presentation/Overview/Detail/View/Subview/AnnouncementDetailView.swift (2)

162-162: Good improvement to respect safe area boundaries.

Anchoring the bottom of the contentStackView to the safe area instead of the superview will prevent content from extending into system UI elements like the home indicator on newer iPhones. This is an important fix for devices with notches or home bars.


175-175: Better alignment for timeLabel.

Aligning the timeLabel with the top of the titleLabel instead of centering it vertically provides more consistent visual positioning, especially when the title spans multiple lines. This improves the layout when titles are long.

Wable-iOS/Presentation/Overview/Rank/View/RankListViewController.swift (2)

37-42: Clean initialization style for UICollectionView

The change from using .init() to directly using the constructor UICollectionView() is a good stylistic improvement that enhances code readability.


63-63: Clean initialization style for CancelBag

Using CancelBag() rather than .init() is a cleaner and more standard way to initialize objects in Swift. This improved consistency with Swift idioms.

Wable-iOS/Infra/Network/DTO/Response/Information/FetchNotices.swift (1)

18-18: Good modification to handle optional image URLs.

Changing noticeImageURL to an optional type (String?) makes the DTO more resilient when handling API responses where the image URL might not be present. This change aligns with best practices for working with potentially nullable API fields.

Since this is a data model change, ensure that any code using this property is updated to handle the optional value correctly, particularly when mapping to domain models.

Wable-iOS/Infra/Network/DTO/Response/Information/FetchNews.swift (1)

18-18: Appropriate change for handling optional news image URLs.

Making newsImageURL optional (String?) is a good approach for handling cases where the API response might not include an image URL. This change is consistent with the similar modification made to the FetchNotices struct.

Make sure any related mappers or presenters properly handle this nullable value to avoid unexpected UI behavior.

Wable-iOS/Presentation/Overview/Notice/View/NoticeViewController.swift (1)

238-238: Improved collection view layout with estimated height.

Changing from .fractionalHeight(1) to .estimated(96.adjustedHeight) is a good improvement for the collection view layout. This approach:

  1. Allows for more accurate height calculations based on content
  2. Improves scrolling performance by providing the system with a realistic height estimate
  3. Better handles variable-height content than a fixed fractional height

This change aligns well with standard UICollectionView best practices for dynamic content.

Wable-iOS/Presentation/Overview/Notice/View/Cell/NoticeCell.swift (1)

90-90: Consider the implications of using a fixed bottom constraint.

Changing from make.bottom.lessThanOrEqualToSuperview().offset(-12) to make.bottom.equalToSuperview().offset(-12) makes the constraint more rigid.

The previous constraint allowed the label's bottom edge to adjust when content was shorter than expected, while ensuring it never got closer than 12 points to the bottom. The new fixed constraint might:

  1. Force a minimum cell height even with minimal content
  2. Potentially cut off text if the content exceeds available space, since numberOfLines is set to 2

Consider if this is the intended behavior or if the more flexible constraint was better for variable content.

Wable-iOS/App/AppDelegate+InjectDependency.swift (1)

14-14: Good implementation of dependency injection.

This change properly registers the InformationRepositoryImpl for the InformationRepository interface in the dependency injection container, which aligns with the PR objective of registering repository dependencies. This enables easier access to the repository through the @Injected property wrapper as mentioned in the PR description.

Wable-iOS/Presentation/Overview/News/View/NewsViewController.swift (2)

35-41: LGTM: Simplified collection view initialization.

The change from using .init() syntax to directly calling the constructor is a good stylistic improvement that makes the code cleaner.


43-46: Note about missing emptyLabel.isHidden setting.

The previous code may have set emptyLabel.isHidden = true initially, which has been removed. This is fine as long as the visibility is properly managed in the setupBinding() method (which it appears to be at line 199).

Wable-iOS/Data/Mapper/InformationMapper.swift (2)

60-60: Good fix for handling optional image URLs.

This change properly handles cases where the newsImageURL might be nil by using the nil-coalescing operator, preventing potential issues when creating URL objects.


76-76: Good fix for handling optional image URLs.

Similar to the news image URL handling, this change properly handles cases where the noticeImageURL might be nil, preventing potential issues when creating URL objects.

Wable-iOS/Presentation/Overview/Page/View/OverviewPageViewController.swift (2)

146-151: Good refactoring to use the UseCase pattern.

The transition from using repository directly to using a UseCase is a good architectural improvement that better separates concerns.


153-160: Improved code organization.

Using an array followed by a forEach loop is a cleaner approach than multiple append calls.

Wable-iOS/Presentation/Overview/GameSchedule/View/GameScheduleListViewController.swift (4)

44-46: Clean replacement of GameScheduleEmptyView with UIImageView

The switch from a custom empty view to a standard UIImageView simplifies the code while maintaining the same functionality. Setting the content mode to .scaleAspectFit ensures the image will be displayed properly.


95-96: Appropriate view hierarchy update

The view hierarchy has been properly updated to include the new emptyImageView in place of the previous emptyView.


104-108: Constraints look good

The constraints correctly center the empty image and set appropriate dimensions with the adjusted sizing helpers to handle different device sizes.


225-225: Visibility logic is correctly implemented

The condition for showing/hiding the empty state has been properly updated to use the new emptyImageView. The logic is correct - show the empty image when there are no items.

Wable-iOS/Presentation/Overview/Detail/View/AnnouncementDetailViewController.swift (3)

37-41: Good UX improvement by hiding tab bar

Setting hidesBottomBarWhenPushed = true in the initializer ensures a cleaner UI when navigating to detail views, which is a good practice for detail screens.


43-46: Correctly preventing storyboard initialization

Marking the required initializer as unavailable with a fatal error is the standard pattern to prevent unintended initialization from Interface Builder.


75-82: Improved image loading error handling

The previous implementation likely didn't handle image loading failures. This update properly shows or hides the image view based on the loading result, providing better user experience when images fail to load.

Wable-iOS/Presentation/Overview/Notice/ViewModel/NoticeViewModel.swift (5)

12-16: Good architectural improvement using UseCase pattern

Replacing direct repository access with a UseCase abstraction follows clean architecture principles and improves separation of concerns. This change aligns with the PR objective of implementing and applying the UseCase pattern.


47-47: Repository access properly delegated to helper method

Using the fetchNotices helper method for both initial and pagination fetch operations provides consistent error handling and improves code organization.

Also applies to: 67-67


49-52: Improved last page detection with helper method

Extracting the last page detection logic to a separate method makes the code more readable and consistent, especially since this logic is used in multiple places.

Also applies to: 69-72


97-105: Well-implemented error handling

The helper method properly catches errors, logs them, and returns an empty array instead of propagating the error. This ensures the UI will still function even if the network request fails.


107-109: Clear and reusable pagination logic

The implementation of isLastPage is clear and follows a standard pattern for determining the end of paginated data.

Wable-iOS/Presentation/Overview/Rank/ViewModel/RankViewModel.swift (3)

12-16: Consistent application of UseCase pattern

The changes in RankViewModel follow the same pattern applied to other view models, replacing repository direct access with UseCase abstraction. This consistency improves the overall architecture.


33-33: Appropriate delegation to UseCase methods

The data fetching calls have been properly updated to use the UseCase methods instead of calling the repository directly, maintaining the same functionality with better architecture.

Also applies to: 38-38


42-43: Streamlined trigger logic

The view load and refresh triggers are now combined directly in the item publisher chain, which simplifies the code.

Wable-iOS/Presentation/Overview/GameSchedule/ViewModel/GameScheduleViewModel.swift (4)

12-12: UseCase property introduction looks good.
No issues found with declaring useCase here. The use of private keeps the property encapsulated.


14-15: Constructor refactor aligns with new architecture.
Replacing the repository parameter with useCase is consistent with the shift to a use case-driven approach.


45-45: Merging triggers is straightforward.
Merging viewDidLoad and viewDidRefresh into a single publisher for subsequent mapping looks correct.


51-51: CombineLatest usage is correct.
Combining fetchGameType and fetchGameSchedules into a single pipeline is a neat approach to retrieve the required data concurrently.

Wable-iOS/Presentation/Overview/News/ViewModel/NewsViewModel.swift (4)

12-12: OverviewUseCase property introduction looks good.
Declaring a private useCase property is consistent with the new architecture.


14-15: Constructor refactor approved.
Switching from repository to useCase in the initializer follows the same pattern found in other view models and is consistent with the domain-driven design.


69-73: Infinite scroll logic is well-handled.
Filtering out the isLastPage condition prevents redundant network calls. The approach for willDisplayLastItem looks good.


99-112: Helper extension provides clear separation of concerns.
Using a dedicated fetchNews(with:) method that logs errors and returns an empty array is a pragmatic fallback. If you’d like to surface errors to the UI eventually, consider revisiting this approach. Also, the isLastPage logic aligns with pagination best practices.

Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (1)

148-173: Incremental approach to generating mock announcements is straightforward.
This chunk-based logic helps test pagination by simulating discrete pages of data. The fallback to .just([]) for unexpected cursors is a sensible default.

Copy link
Member

@youz2me youz2me left a comment

Choose a reason for hiding this comment

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

굿 !! 고생하셨습니다 작업 속도가 빠르시군요 ,,, 저도 분발하겠습니다.

init() {
super.init(nibName: nil, bundle: nil)

hidesBottomBarWhenPushed = true
Copy link
Member

Choose a reason for hiding this comment

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

좋은 지식 알아갑니다 ,,,

mockGameSchedules.append(GameSchedule(date: date, games: games))
}

// return .just(mockGameSchedules)
Copy link
Member

Choose a reason for hiding this comment

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

필요없는 주석은 삭제 부탁드립니닷 !!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 반영했습니다!

JinUng41 added 2 commits April 1, 2025 00:21
# Conflicts:
#	Wable-iOS/Presentation/Overview/Rank/View/RankListViewController.swift
#	Wable-iOS/Presentation/Overview/Rank/ViewModel/RankViewModel.swift
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 (2)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (2)

47-55: Address the TODO in checkNewAnnouncements().
You have a placeholder returning (false, false). Completing this step is essential to ensure that the announcements are correctly checked against any locally stored reference.

Would you like assistance implementing the comparison logic or opening a new issue to track this?

🧰 Tools
🪛 SwiftLint (0.57.0)

[Warning] 49-49: TODOs should be resolved (서버에서 받아오는 값과 로컬에 저장한 값을 비교 후, ...)

(todo)


60-63: Consider parameterizing the random delay in mocks.
Using randomDelaySecond is helpful to simulate asynchronous calls but may cause non-deterministic test outcomes. Consider adding a configurable parameter for test stability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de41963 and 84a0b8c.

📒 Files selected for processing (4)
  • Wable-iOS.xcodeproj/project.pbxproj (0 hunks)
  • Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (1 hunks)
  • Wable-iOS/Presentation/Overview/Rank/View/RankListViewController.swift (2 hunks)
  • Wable-iOS/Presentation/Overview/Rank/ViewModel/RankViewModel.swift (2 hunks)
💤 Files with no reviewable changes (1)
  • Wable-iOS.xcodeproj/project.pbxproj
🚧 Files skipped from review as they are similar to previous changes (2)
  • Wable-iOS/Presentation/Overview/Rank/View/RankListViewController.swift
  • Wable-iOS/Presentation/Overview/Rank/ViewModel/RankViewModel.swift
🧰 Additional context used
🧬 Code Definitions (1)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (1)
Wable-iOS/Data/RepositoryImpl/InformationRepositoryImpl.swift (5)
  • fetchGameCategory (27-34)
  • fetchGameSchedules (18-25)
  • fetchTeamRanks (36-43)
  • fetchNews (54-61)
  • fetchNotice (63-70)
🪛 SwiftLint (0.57.0)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift

[Warning] 49-49: TODOs should be resolved (서버에서 받아오는 값과 로컬에 저장한 값을 비교 후, ...)

(todo)

🔇 Additional comments (2)
Wable-iOS/Domain/UseCase/Overview/OverviewUseCase.swift (2)

13-20: Great use of a dedicated protocol.
This OverviewUseCase protocol clearly defines the responsibilities and return types for fetching various data. The structure is easy to read and helps maintain a clean separation of concerns.


25-25:

Details

✅ Verification successful

Verify DI container registration.
Ensure that InformationRepositoryImpl is properly registered for dependency injection so that @Injected private var repository resolves at runtime without errors.


🏁 Script executed:

#!/bin/bash
# Description: Verify that `InformationRepositoryImpl` is registered in DIContainer
rg -A 5 "InformationRepositoryImpl" 

Length of output: 5088


DI Container Registration Confirmed
The DI container registration for InformationRepositoryImpl is properly set up. In Wable-iOS/App/AppDelegate+InjectDependency.swift, the following registration is observed:

diContainer.register(for: InformationRepository.self, object: InformationRepositoryImpl())

No further modifications are required.

Comment on lines +102 to +129
private func createMockGameSchedules() -> AnyPublisher<[GameSchedule], WableError> {
var mockGameSchedules: [GameSchedule] = []

for dayOffset in 0...6 {
let date = Calendar.current.date(byAdding: .day, value: dayOffset, to: Date())!
var games: [Game] = []

for index in 0...4 {
let homeTeamIndex = index * 2 % lckTeams.count
let awayTeamIndex = (index * 2 + 1) % lckTeams.count

let game = Game(
date: date,
homeTeam: lckTeams[homeTeamIndex],
homeScore: index * 2 + 1,
awayTeam: lckTeams[awayTeamIndex],
awayScore: index * 2 + 2,
status: .scheduled
)
games.append(game)
}

mockGameSchedules.append(GameSchedule(date: date, games: games))
}

return .just([])
}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the return value to use the constructed schedules.
In createMockGameSchedules(), the function builds a non-empty mockGameSchedules array but returns .just([]) instead. This likely causes incorrect mock data in the UI or tests.

Apply this diff to fix the issue:

- return .just([])
+ return .just(mockGameSchedules)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private func createMockGameSchedules() -> AnyPublisher<[GameSchedule], WableError> {
var mockGameSchedules: [GameSchedule] = []
for dayOffset in 0...6 {
let date = Calendar.current.date(byAdding: .day, value: dayOffset, to: Date())!
var games: [Game] = []
for index in 0...4 {
let homeTeamIndex = index * 2 % lckTeams.count
let awayTeamIndex = (index * 2 + 1) % lckTeams.count
let game = Game(
date: date,
homeTeam: lckTeams[homeTeamIndex],
homeScore: index * 2 + 1,
awayTeam: lckTeams[awayTeamIndex],
awayScore: index * 2 + 2,
status: .scheduled
)
games.append(game)
}
mockGameSchedules.append(GameSchedule(date: date, games: games))
}
return .just([])
}
private func createMockGameSchedules() -> AnyPublisher<[GameSchedule], WableError> {
var mockGameSchedules: [GameSchedule] = []
for dayOffset in 0...6 {
let date = Calendar.current.date(byAdding: .day, value: dayOffset, to: Date())!
var games: [Game] = []
for index in 0...4 {
let homeTeamIndex = index * 2 % lckTeams.count
let awayTeamIndex = (index * 2 + 1) % lckTeams.count
let game = Game(
date: date,
homeTeam: lckTeams[homeTeamIndex],
homeScore: index * 2 + 1,
awayTeam: lckTeams[awayTeamIndex],
awayScore: index * 2 + 2,
status: .scheduled
)
games.append(game)
}
mockGameSchedules.append(GameSchedule(date: date, games: games))
}
return .just(mockGameSchedules)
}

@JinUng41 JinUng41 merged commit 45ab6f0 into develop Mar 31, 2025
1 check passed
@JinUng41 JinUng41 deleted the fix/#154-overview-error branch March 31, 2025 15:25
@github-project-automation github-project-automation bot moved this from In Review to Done in Wable-iOS Mar 31, 2025
youz2me pushed a commit that referenced this pull request Oct 26, 2025
[Fix] 소식 탭 오류 수정 및 유즈케이스 구현 및 적용
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍻 진웅 술 한잔 가온나~ 🛠️ fix 기능적 버그나 오류 해결 시 사용

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Fix] 소식 탭 UI 오류 수정 및 UseCase 적용

3 participants