Skip to content

refactor: 하이라이트 타입을 HighlightStyle enum으로 전환 - #104

Merged
gomminjae merged 1 commit into
developfrom
refactor/highlight-style-enum
Jun 9, 2026
Merged

gomminjae merged 1 commit into
developfrom
refactor/highlight-style-enum

Conversation

@gomminjae

Copy link
Copy Markdown
Collaborator

배경

Article Highlight 영역의 색/밑줄 타입이 stringly-typed("yellow"/"underline" 등)로 JS·ViewModel·Repository 3중 중복돼 오타에 취약했음. Article Highlight 리팩토링 설계의 0단계(가장 저위험).

변경

  • HighlightStyle enum 신설 (DetailDomain, String rawValue)
  • DetailHighlight.highlightType: String → style: HighlightStyle
  • Repository: addHighlight(type:)→(style:), changeHighlightType→changeHighlightStyle
  • 영속화(DatabaseKit)는 String 유지 — 변환은 Repository 경계에서 rawValue / init?(rawValue:)로만
  • JS 콜백 String→enum 변환은 WebView seam에서만 수행
  • HighlightListView switch를 enum exhaustive로 (default 제거)

테스트

  • HighlightStyleTests: JS 브릿지 문자열 계약(rawValue), rawValue 라운드트립, unknown→nil
  • 기존 DetailTests/Mock/Sample 갱신

검증

  • Detail 스킴 빌드 통과 (BUILD SUCCEEDED)

비고

  • 이후 단계(메시지 버스 단일화 → 포트 도입 → TS 엔진 → HighlightLocator)는 후속 PR로 분리
  • Detail 모듈 분리(Brand/Reader)는 별도 후속 과제로 식별됨

stringly-typed highlightType("yellow"/"underline" 등)을 HighlightStyle enum으로
대체해 JS·VM·Repo 3중 중복과 오타 위험 제거. 영속화(DatabaseKit)는 String을
유지하고 Repository 경계에서 rawValue로만 변환. JS 브릿지 문자열 계약을
검증하는 HighlightStyleTests 추가.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces raw String types for highlight styles with a structured HighlightStyle enum across the detail feature module, updating repositories, models, view models, and views accordingly, and adds corresponding unit tests. The review feedback points out that the String to HighlightStyle conversion is currently being handled in ArticleDetailView rather than being encapsulated within the WebView seam (ArticleWebView) as intended, and suggests refactoring the web view's callback signatures to accept HighlightStyle directly.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +45 to +46
onSaveHighlight: { color in viewModel.saveHighlight(style: HighlightStyle(rawValue: color) ?? .yellow) },
onHighlightTypeChanged: { text, newType in viewModel.changeHighlightStyle(text: text, to: HighlightStyle(rawValue: newType) ?? .yellow) },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

PR 설명에 'JS 콜백 String→enum 변환은 WebView seam에서만 수행'이라고 명시되어 있으나, 현재 ArticleDetailView에서 HighlightStyle(rawValue:)를 통해 직접 변환을 수행하고 있습니다.\n\nArticleWebView가 이미 DetailDomain을 임포트하고 있으므로, ArticleWebView 내부의 콜백 클로저 타입을 String 대신 HighlightStyle로 변경하는 것이 좋습니다.\n\n추가 가이드:\n이 제안을 적용하려면 ArticleWebView.swift 파일에서 onSaveHighlight와 onHighlightTypeChanged 클로저의 타입을 String 대신 HighlightStyle을 받도록 변경해야 합니다.\n\nswift\n// ArticleWebView.swift\nvar onSaveHighlight: ((HighlightStyle) -> Void)?\nvar onHighlightTypeChanged: ((String, HighlightStyle) -> Void)?\n\n\n그리고 ArticleWebView.Coordinator에서 JS 메시지를 수신하여 처리할 때 HighlightStyle(rawValue:) 변환을 수행하도록 수정하면, 뷰 레이어(ArticleDetailView)에 문자열 타입이 노출되지 않고 설계 의도대로 WebView seam 내부에서만 변환이 완결됩니다.

Suggested change
onSaveHighlight: { color in viewModel.saveHighlight(style: HighlightStyle(rawValue: color) ?? .yellow) },
onHighlightTypeChanged: { text, newType in viewModel.changeHighlightStyle(text: text, to: HighlightStyle(rawValue: newType) ?? .yellow) },
onSaveHighlight: { style in viewModel.saveHighlight(style: style) },
onHighlightTypeChanged: { text, style in viewModel.changeHighlightStyle(text: text, to: style) },

@gomminjae
gomminjae merged commit 06c93f5 into develop Jun 9, 2026
1 check passed
@gomminjae
gomminjae deleted the refactor/highlight-style-enum branch June 9, 2026 07:12
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