-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 내서재 도서 검색 기능 구현 #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
444eb3b
[BOOK-167] chore: search 모듈 내에 도서 검색 과련 파일을 book 패키지로 분리
seoyoon513 e6d6673
[BOOK-167] feat: 내서재 검색 화면 기본 구성 및 navigation 연결
seoyoon513 9f9efe8
[BOOK-167] feat: ReedSearchTextField 파라미터 추가 및 기본값 수정
seoyoon513 c86f37b
[BOOK-167] feat: 내서재 검색 화면 1차 작업
seoyoon513 ca52cb6
[BOOK-167] feat: 내서재 검색 API 정의
seoyoon513 695a619
[BOOK-167] feat: 내서재 검색 API 연동
seoyoon513 88de4ec
[BOOK-167] feat: OnLoadMore, OnRetryClick 이벤트에서 공백 문자열 방지
seoyoon513 8a4a647
[BOOK-167] feat: 내서재 최근 검색어 DataStore 구축 및 RecentSearch를 도서(Book)/내서재…
seoyoon513 f8b52a9
[BOOK-167] feat: 내서재 최근 검색어 조회, 삭제 기능 구현
seoyoon513 764772b
[BOOK-167] feat: 도서 검색에서 쿼리 유효성 검사 추가 (빈문자열, 공백 차단)
seoyoon513 ee87a22
[BOOK-167] feat: 내서재 페이징 조회 PAGE_SIZE 변경
seoyoon513 345fe0a
[BOOK-167] chore: code style check success
seoyoon513 6bed0bc
[BOOK-167] chore: 공통 컴포넌트를 common으로 분리
seoyoon513 78b28d4
Merge branch 'develop' into BOOK-167-feature/#69
seoyoon513 82fde36
[BOOK-167] chore: 필드명 변경 (isbn -> isbn13)
seoyoon513 bc0d3d4
[BOOK-167] fix: 최근 검색어 선택 시 queryState 미반영으로 페이징 실패 문제 수정
seoyoon513 da74fff
[BOOK-167] feat: HandlingLibrarySearchSideEffect 추가
seoyoon513 9aeb51f
[BOOK-167] refactor: 필터 기반 조회 / 검색 기반 조회를 명확하게 구분할 수 있도록 함수 네이밍 수정
seoyoon513 868e30f
[BOOK-167] refactor: Search prefix를 BookSearch로 수정
seoyoon513 462fe4f
[BOOK-167] chore: 에러 메세지 수정
seoyoon513 276d695
[BOOK-167] chore: DataStore Name 수정
seoyoon513 1d6fb69
[BOOK-167] chore: 파라미터 네이밍 수정 isbn -> isbn13
seoyoon513 06231f5
[BOOK-167] chore: OnSearchClick에서 trim된 쿼리로 검색하도록 수정
seoyoon513 95283d8
[BOOK-167] chore: 파라미터 네이밍 수정 isbn -> isbn13
seoyoon513 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...n/kotlin/com/ninecraft/booket/core/datastore/api/datasource/BookRecentSearchDataSource.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package com.ninecraft.booket.core.datastore.api.datasource | ||
|
|
||
| interface BookRecentSearchDataSource : RecentSearchDataSource |
3 changes: 3 additions & 0 deletions
3
...otlin/com/ninecraft/booket/core/datastore/api/datasource/LibraryRecentSearchDataSource.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package com.ninecraft.booket.core.datastore.api.datasource | ||
|
|
||
| interface LibraryRecentSearchDataSource : RecentSearchDataSource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...m/ninecraft/booket/core/datastore/impl/datasource/DefaultLibraryRecentSearchDataSource.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| package com.ninecraft.booket.core.datastore.impl.datasource | ||
|
|
||
| import androidx.datastore.core.DataStore | ||
| import androidx.datastore.preferences.core.Preferences | ||
| import androidx.datastore.preferences.core.edit | ||
| import androidx.datastore.preferences.core.stringPreferencesKey | ||
| import com.ninecraft.booket.core.datastore.api.datasource.LibraryRecentSearchDataSource | ||
| import com.ninecraft.booket.core.datastore.impl.di.LibraryRecentSearchDataStore | ||
| import com.ninecraft.booket.core.datastore.impl.util.handleIOException | ||
| import com.orhanobut.logger.Logger | ||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.map | ||
| import kotlinx.serialization.SerializationException | ||
| import kotlinx.serialization.json.Json | ||
| import javax.inject.Inject | ||
|
|
||
| class DefaultLibraryRecentSearchDataSource @Inject constructor( | ||
| @LibraryRecentSearchDataStore private val dataStore: DataStore<Preferences>, | ||
| ) : LibraryRecentSearchDataSource { | ||
| @Suppress("TooGenericExceptionCaught") | ||
| override val recentSearches: Flow<List<String>> = dataStore.data | ||
| .handleIOException() | ||
| .map { prefs -> | ||
| prefs[LIBRARY_RECENT_SEARCHES]?.let { jsonString -> | ||
| try { | ||
| Json.decodeFromString<List<String>>(jsonString) | ||
| } catch (e: SerializationException) { | ||
| Logger.e(e, "Failed to deserialize recent searches") | ||
| emptyList() | ||
| } catch (e: Exception) { | ||
| Logger.e(e, "Unexpected error while reading recent searches") | ||
| emptyList() | ||
| } | ||
| } ?: emptyList() | ||
| } | ||
|
|
||
| @Suppress("TooGenericExceptionCaught") | ||
| override suspend fun addRecentSearch(query: String) { | ||
| if (query.isBlank()) return | ||
|
|
||
| dataStore.edit { prefs -> | ||
| val currentSearches = prefs[LIBRARY_RECENT_SEARCHES]?.let { jsonString -> | ||
| try { | ||
| Json.decodeFromString<List<String>>(jsonString).toMutableList() | ||
| } catch (e: SerializationException) { | ||
| Logger.e(e, "Failed to deserialize recent searches for adding") | ||
| mutableListOf() | ||
| } catch (e: Exception) { | ||
| Logger.e(e, "Unexpected error while adding recent search") | ||
| mutableListOf() | ||
| } | ||
| } ?: mutableListOf() | ||
|
|
||
| // 기존에 있으면 제거 (upsert 로직) | ||
| currentSearches.remove(query) | ||
| // 맨 앞에 추가 (가장 최근 검색어) | ||
| currentSearches.add(0, query) | ||
|
|
||
| // 최근 10개만 유지 | ||
| val limitedSearches = currentSearches.take(MAX_SEARCH_COUNT) | ||
| try { | ||
| prefs[LIBRARY_RECENT_SEARCHES] = Json.encodeToString(limitedSearches) | ||
| } catch (e: SerializationException) { | ||
| Logger.e(e, "Failed to serialize recent searches") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Suppress("TooGenericExceptionCaught") | ||
| override suspend fun removeRecentSearch(query: String) { | ||
| dataStore.edit { prefs -> | ||
| val currentSearches = prefs[LIBRARY_RECENT_SEARCHES]?.let { jsonString -> | ||
| try { | ||
| Json.decodeFromString<List<String>>(jsonString).toMutableList() | ||
| } catch (e: SerializationException) { | ||
| Logger.e(e, "Failed to deserialize recent searches for removal") | ||
| mutableListOf() | ||
| } catch (e: Exception) { | ||
| Logger.e(e, "Unexpected error while removing recent search") | ||
| mutableListOf() | ||
| } | ||
| } ?: mutableListOf() | ||
|
|
||
| currentSearches.remove(query) | ||
| try { | ||
| prefs[LIBRARY_RECENT_SEARCHES] = Json.encodeToString(currentSearches) | ||
| } catch (e: SerializationException) { | ||
| Logger.e(e, "Failed to serialize recent searches after removal") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override suspend fun clearRecentSearches() { | ||
| dataStore.edit { prefs -> | ||
| prefs.remove(LIBRARY_RECENT_SEARCHES) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private val LIBRARY_RECENT_SEARCHES = stringPreferencesKey("LIBRARY_RECENT_SEARCHES") | ||
| private const val MAX_SEARCH_COUNT = 10 | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.