Skip to content

Commit 4344267

Browse files
committed
[BOOK-250] refactor: 빈 isbn이 대응 로직 추가
- LazyColumn item key를 title-isbn13 조합으로 변경 - BookItem 클릭 시 isbn이 비어 있으면 토스트 메세지로 안내
1 parent 8090ee7 commit 4344267

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

core/data/impl/src/main/kotlin/com/ninecraft/booket/core/data/impl/mapper/ResponseToModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ internal fun BookSummary.toModel(): BookSummaryModel {
7575
coverImageUrl = coverImageUrl,
7676
link = link,
7777
userBookStatus = userBookStatus,
78+
key = "$title-$isbn13",
7879
)
7980
}
8081

core/model/src/main/kotlin/com/ninecraft/booket/core/model/BookSearchModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ data class BookSummaryModel(
2626
val coverImageUrl: String = "",
2727
val link: String = "",
2828
val userBookStatus: String = "",
29+
val key: String = "",
2930
)

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/book/BookSearchPresenter.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class BookSearchPresenter @AssistedInject constructor(
4040
private val repository: BookRepository,
4141
) : Presenter<BookSearchUiState> {
4242
companion object {
43-
private const val PAGE_SIZE = 20
4443
private const val START_INDEX = 1
4544
}
4645

@@ -185,7 +184,12 @@ class BookSearchPresenter @AssistedInject constructor(
185184

186185
is BookSearchUiEvent.OnBookClick -> {
187186
selectedBookIsbn = event.isbn13
188-
isBookRegisterBottomSheetVisible = true
187+
188+
if (selectedBookIsbn.isEmpty()) {
189+
sideEffect = BookSearchSideEffect.ShowToast("isbn이 없는 도서는 등록할 수 없습니다")
190+
} else {
191+
isBookRegisterBottomSheetVisible = true
192+
}
189193
}
190194

191195
is BookSearchUiEvent.OnBookRegisterBottomSheetDismiss -> {

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/book/BookSearchUi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ internal fun SearchContent(
222222
) {
223223
items(
224224
count = state.books.size,
225-
key = { index -> state.books[index].isbn13 },
225+
key = { index -> state.books[index].key },
226226
) { index ->
227227
Column {
228228
BookItem(

0 commit comments

Comments
 (0)