Conversation
✅ PR의 Assign 자동 지정을 성공했어요! |
There was a problem hiding this comment.
Summary of Changes
Hello @baekteun, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
이 PR은 독서 기록 및 인용구 관리 기능을 개선합니다. 사용자가 독서 기록과 인용구를 쉽게 편집하고 삭제할 수 있도록 ContextMenu와 Trailing Swipe Action을 추가하며, 고화질 이미지 로딩과 데이터 새로고침 기능을 구현하여 사용자 경험을 향상시킵니다.
Highlights
- 독서 기록 편집/삭제 기능 추가: ContextMenu와 Trailing Swipe Action을 통해 독서 기록을 편집하고 삭제할 수 있습니다.
- 인용구 편집/삭제 기능 추가: ContextMenu와 Trailing Swipe Action을 통해 인용구에 대한 편집 및 삭제 기능을 지원합니다 (현재 TODO 상태).
- 고화질 이미지 로딩: Google Books API에서 extraLarge 이미지 링크를 우선적으로 사용하고, 이미지 URL에 고화질 파라미터를 추가하여 더 선명한 이미지를 로딩합니다.
- 데이터 새로고침 지원: 독서 기록 저장 또는 삭제 후 관련 데이터를 자동으로 새로고침하여 최신 상태를 유지합니다.
- BookRecordEditorViewController 통합 개선: 저장 완료 시 콜백을 통해 데이터 새로고침을 트리거할 수 있도록 BookRecordEditorViewController가 개선되었습니다.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
| self.thumbnailURL = URL(string: secureURL) | ||
| if let baseURL = URL(string: secureURL) { | ||
| var urlComponents = URLComponents(url: baseURL, resolvingAgainstBaseURL: false) | ||
| urlComponents?.queryItems?.append(URLQueryItem(name: "fife", value: "w400-h600")) |
There was a problem hiding this comment.
urlComponents.queryItems가 nil일 수 있는데, 이 경우 ?.append(...)는 아무 작업도 수행하지 않습니다. 이로 인해 fife 쿼리 파라미터가 추가되지 않는 버그가 발생할 수 있습니다. queryItems가 nil인 경우를 처리하도록 코드를 수정해야 합니다.
| urlComponents?.queryItems?.append(URLQueryItem(name: "fife", value: "w400-h600")) | |
| urlComponents?.queryItems = (urlComponents?.queryItems ?? []) + [URLQueryItem(name: "fife", value: "w400-h600")] |
| func collectionView( | ||
| _ collectionView: UICollectionView, | ||
| contextMenuConfiguration configuration: UIContextMenuConfiguration, | ||
| highlightPreviewForItemAt indexPath: IndexPath | ||
| ) -> UITargetedPreview? { | ||
| guard let item = dataSource.itemIdentifier(for: indexPath) else { return nil } | ||
|
|
||
| switch item { | ||
| case .readingLog: | ||
| guard let cell = collectionView.cellForItem(at: indexPath) as? BookDetailViewController.ReadingLogCell, | ||
| let highlightView = cell.contextMenuHighlightView() else { | ||
| return nil | ||
| } | ||
|
|
||
| let parameters = UIPreviewParameters() | ||
| parameters.backgroundColor = .clear | ||
|
|
||
| return UITargetedPreview(view: highlightView, parameters: parameters) | ||
|
|
||
| case .quote: | ||
| guard let cell = collectionView.cellForItem(at: indexPath) as? BookDetailViewController.QuoteCell, | ||
| let highlightView = cell.contextMenuHighlightView() else { | ||
| return nil | ||
| } | ||
|
|
||
| let parameters = UIPreviewParameters() | ||
| parameters.backgroundColor = .clear | ||
|
|
||
| return UITargetedPreview(view: highlightView, parameters: parameters) | ||
|
|
||
| default: | ||
| return nil | ||
| } | ||
| } |
There was a problem hiding this comment.
이 메서드와 collectionView(_:contextMenuConfiguration:dismissalPreviewForItemAt:) 메서드의 내용이 거의 동일하여 코드 중복이 발생하고 있습니다. 중복을 제거하고 코드를 더 간결하게 만들기 위해, 공통 로직을 별도의 private 헬퍼 메서드로 추출하는 것을 고려해 보세요. 이렇게 하면 유지보수성이 향상됩니다.
예를 들어, 다음과 같은 헬퍼 메서드를 만들 수 있습니다:
private func getContextMenuTargetedPreview(forItemAt indexPath: IndexPath) -> UITargetedPreview? {
guard let item = dataSource.itemIdentifier(for: indexPath) else { return nil }
let cell = collectionView.cellForItem(at: indexPath)
var highlightView: UIView?
switch item {
case .readingLog:
highlightView = (cell as? ReadingLogCell)?.contextMenuHighlightView()
case .quote:
highlightView = (cell as? QuoteCell)?.contextMenuHighlightView()
default:
return nil
}
guard let viewToHighlight = highlightView else { return nil }
let parameters = UIPreviewParameters()
parameters.backgroundColor = .clear
return UITargetedPreview(view: viewToHighlight, parameters: parameters)
}그런 다음 두 UICollectionViewDelegate 메서드에서 이 헬퍼 메서드를 호출하면 됩니다.
| private func showAddNewRecord() { | ||
| print("Add new reading record tapped") | ||
| guard let book = viewModel.book else { return } | ||
|
|
||
| let recordViewModel = BookRecordEditorViewModel(book: book, editMode: .create) | ||
| let recordViewController = BookRecordEditorViewController(viewModel: recordViewModel) { [weak self] in | ||
| self?.refreshBookData() | ||
| } | ||
| let navigationController = UINavigationController(rootViewController: recordViewController) | ||
|
|
||
| if let sheet = navigationController.sheetPresentationController { | ||
| sheet.detents = [.medium(), .large()] | ||
| sheet.prefersGrabberVisible = true | ||
| } | ||
|
|
||
| present(navigationController, animated: true) | ||
| } | ||
|
|
||
| private func showAddNewQuote() { | ||
| print("Add new quote tapped") | ||
| } | ||
|
|
||
| private func refreshBookData() { | ||
| viewModel.loadBook(with: bookObjectID) | ||
| } | ||
|
|
||
| private func showEditReadingLog(_ readingLog: ReadingLogEntity) { | ||
| guard let book = viewModel.book else { return } | ||
|
|
||
| let recordViewModel = BookRecordEditorViewModel(book: book, editMode: .edit(readingLog)) | ||
| let recordViewController = BookRecordEditorViewController(viewModel: recordViewModel) { [weak self] in | ||
| self?.refreshBookData() | ||
| } | ||
| let navigationController = UINavigationController(rootViewController: recordViewController) | ||
|
|
||
| if let sheet = navigationController.sheetPresentationController { | ||
| sheet.detents = [.medium(), .large()] | ||
| sheet.prefersGrabberVisible = true | ||
| } | ||
|
|
||
| present(navigationController, animated: true) | ||
| } |
There was a problem hiding this comment.
showAddNewRecord() 메서드와 showEditReadingLog(_:) 메서드에 BookRecordEditorViewController를 생성하고 표시하는 로직이 중복되어 있습니다. 이 로직을 하나의 private 헬퍼 메서드로 추출하여 코드 중복을 줄이고 재사용성을 높일 수 있습니다.
예를 들어, 다음과 같은 헬퍼 메서드를 만들 수 있습니다.
private func showBookRecordEditor(with editMode: BookRecordEditorViewModel.EditMode) {
guard let book = viewModel.book else { return }
let recordViewModel = BookRecordEditorViewModel(book: book, editMode: editMode)
let recordViewController = BookRecordEditorViewController(viewModel: recordViewModel) { [weak self] in
self?.refreshBookData()
}
let navigationController = UINavigationController(rootViewController: recordViewController)
if let sheet = navigationController.sheetPresentationController {
sheet.detents = [.medium(), .large()]
sheet.prefersGrabberVisible = true
}
present(navigationController, animated: true)
}그런 다음 showAddNewRecord()와 showEditReadingLog(_:)에서 이 헬퍼 메서드를 호출하도록 수정하면 코드가 더 간결해집니다.
private func showAddNewRecord() {
showBookRecordEditor(with: .create)
}
private func showEditReadingLog(_ readingLog: ReadingLogEntity) {
showBookRecordEditor(with: .edit(readingLog))
}| } | ||
| } catch { | ||
| await MainActor.run { | ||
| let count = readingLogs.count |
💡 배경 및 개요
ReadingLog 편집 추가
📃 작업내용
✅ PR 체크리스트
.env,노션,README)"API 개발 완료됐어요","환경값 추가되었어요")🎸 기타