Skip to content

Commit 9aeb51f

Browse files
committed
[BOOK-167] refactor: 필터 기반 조회 / 검색 기반 조회를 명확하게 구분할 수 있도록 함수 네이밍 수정
1 parent da74fff commit 9aeb51f

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

core/data/api/src/main/kotlin/com/ninecraft/booket/core/data/api/repository/BookRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ interface BookRepository {
2424
bookStatus: String,
2525
): Result<BookUpsertModel>
2626

27-
suspend fun getLibrary(
27+
suspend fun filterLibraryBooks(
2828
status: String?,
2929
page: Int,
3030
size: Int,
3131
): Result<LibraryModel>
3232

33-
suspend fun searchLibrary(
33+
suspend fun searchLibraryBooks(
3434
title: String,
3535
page: Int,
3636
size: Int,

core/data/impl/src/main/kotlin/com/ninecraft/booket/core/data/impl/repository/DefaultBookRepository.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ internal class DefaultBookRepository @Inject constructor(
4242
service.upsertBook(BookUpsertRequest(bookIsbn, bookStatus)).toModel()
4343
}
4444

45-
override suspend fun getLibrary(status: String?, page: Int, size: Int) = runSuspendCatching {
46-
service.getLibrary(status, null, page, size).toModel()
45+
override suspend fun filterLibraryBooks(status: String?, page: Int, size: Int) = runSuspendCatching {
46+
service.getLibraryBooks(status, null, page, size).toModel()
4747
}
4848

49-
override suspend fun searchLibrary(title: String, page: Int, size: Int) = runSuspendCatching {
50-
val result = service.getLibrary(null, title, page, size).toModel()
49+
override suspend fun searchLibraryBooks(title: String, page: Int, size: Int) = runSuspendCatching {
50+
val result = service.getLibraryBooks(null, title, page, size).toModel()
5151

5252
libraryRecentSearchDataSource.addRecentSearch(title)
5353
result

core/network/src/main/kotlin/com/ninecraft/booket/core/network/service/ReedService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ interface ReedService {
6464
suspend fun upsertBook(@Body bookUpsertRequest: BookUpsertRequest): BookUpsertResponse
6565

6666
@GET("api/v1/books/my-library")
67-
suspend fun getLibrary(
67+
suspend fun getLibraryBooks(
6868
@Query("status") status: String? = null,
6969
@Query("title") title: String? = null,
7070
@Query("page") page: Int,

feature/library/src/main/kotlin/com/ninecraft/booket/feature/library/LibraryPresenter.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ class LibraryPresenter @AssistedInject constructor(
5252
var currentPage by rememberRetained { mutableIntStateOf(START_INDEX) }
5353
var isLastPage by rememberRetained { mutableStateOf(false) }
5454

55-
fun getLibraryBooks(status: String?, page: Int, size: Int) {
55+
fun filterLibraryBooks(status: String?, page: Int, size: Int) {
5656
scope.launch {
5757
if (page == START_INDEX) {
5858
uiState = UiState.Loading
5959
} else {
6060
footerState = FooterState.Loading
6161
}
6262

63-
repository.getLibrary(status = status, page = page, size = size)
63+
repository.filterLibraryBooks(status = status, page = page, size = size)
6464
.onSuccess { result ->
6565
filterChips = filterChips.map { chip ->
6666
when (chip.option) {
@@ -115,7 +115,7 @@ class LibraryPresenter @AssistedInject constructor(
115115

116116
is LibraryUiEvent.OnFilterClick -> {
117117
currentFilter = event.filterOption
118-
getLibraryBooks(status = currentFilter.getApiValue(), page = START_INDEX, size = PAGE_SIZE)
118+
filterLibraryBooks(status = currentFilter.getApiValue(), page = START_INDEX, size = PAGE_SIZE)
119119
}
120120

121121
is LibraryUiEvent.OnBookClick -> {
@@ -124,19 +124,19 @@ class LibraryPresenter @AssistedInject constructor(
124124

125125
is LibraryUiEvent.OnLoadMore -> {
126126
if (footerState !is FooterState.Loading && !isLastPage) {
127-
getLibraryBooks(status = currentFilter.getApiValue(), page = currentPage + 1, size = PAGE_SIZE)
127+
filterLibraryBooks(status = currentFilter.getApiValue(), page = currentPage + 1, size = PAGE_SIZE)
128128
}
129129
}
130130

131131
is LibraryUiEvent.OnRetryClick -> {
132-
getLibraryBooks(status = currentFilter.getApiValue(), page = currentPage, size = PAGE_SIZE)
132+
filterLibraryBooks(status = currentFilter.getApiValue(), page = currentPage, size = PAGE_SIZE)
133133
}
134134
}
135135
}
136136

137137
LaunchedEffect(Unit) {
138138
if (uiState == UiState.Idle || uiState is UiState.Error) {
139-
getLibraryBooks(
139+
filterLibraryBooks(
140140
status = currentFilter.getApiValue(),
141141
page = START_INDEX,
142142
size = PAGE_SIZE,

feature/search/src/main/kotlin/com/ninecraft/booket/feature/search/library/LibrarySearchPresenter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import com.ninecraft.booket.core.ui.component.FooterState
1515
import com.ninecraft.booket.feature.screens.BookDetailScreen
1616
import com.ninecraft.booket.feature.screens.LibrarySearchScreen
1717
import com.ninecraft.booket.feature.screens.LoginScreen
18-
import com.ninecraft.booket.feature.search.book.SearchSideEffect
1918
import com.orhanobut.logger.Logger
2019
import com.slack.circuit.codegen.annotations.CircuitInject
2120
import com.slack.circuit.retained.collectAsRetainedState
@@ -62,7 +61,7 @@ class LibrarySearchPresenter @AssistedInject constructor(
6261
footerState = FooterState.Loading
6362
}
6463

65-
repository.searchLibrary(title = query, page = page, size = size)
64+
repository.searchLibraryBooks(title = query, page = page, size = size)
6665
.onSuccess { result ->
6766
books = if (result.books.page.number == START_INDEX) {
6867
result.books.content.toPersistentList()

0 commit comments

Comments
 (0)