-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Search backend #668
Search backend #668
Conversation
This CL adds an UI skeleton of the search feature including: - The search navigation icon in the NiaTopAppBar - The text field to enter the search query - Almost empty ViewModel Bug: 216019540 Change-Id: Ic2355a7634e5c5c60f72276741175d9e637db5eb
Change-Id: I70a0732f67617a96b6dd20eccbc6c02a9dafdabd
Change-Id: Id9efb259bd8ac6a83af19fb370869aa19f78831d
- Empty search screen if the search result is empty - Topics contents that reuses the TopicsTabContent for InterestsScreen - Updates contents that reuses the newsFeed for ForYouScreen TODO: Needs to add RecentSearch Change-Id: I19179336a60b5165e8b59508fb03dd8f55a16f96
Change-Id: I5b87f89d824961cb9aec039281e784d6dec0716b
Change-Id: I103c903c936137c41d7d11be0731438d9ee557d9
...com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt
Outdated
Show resolved
Hide resolved
.../search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
Show resolved
Hide resolved
.../search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
Outdated
Show resolved
Hide resolved
...ure/search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
Outdated
Show resolved
Hide resolved
Change-Id: If336af8fa5c58d6401dfd7a561a1a340ff388175
Change-Id: I94aefab87ff9e05819800c516a0f2979f5f89d76
...com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt
Show resolved
Hide resolved
...com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt
Show resolved
Hide resolved
.../search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
.../search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great feature, neatly implemented. Just a couple of nits and questions.
...com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt
Show resolved
Hide resolved
...m/google/samples/apps/nowinandroid/core/data/repository/fake/FakeSearchContentsRepository.kt
Outdated
Show resolved
Hide resolved
.../main/java/com/google/samples/apps/nowinandroid/core/database/model/NewsResourceFtsEntity.kt
Show resolved
Hide resolved
...n/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsUseCase.kt
Outdated
Show resolved
Hide resolved
...n/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsUseCase.kt
Outdated
Show resolved
Hide resolved
...com/google/samples/apps/nowinandroid/core/testing/repository/TestSearchContentsRepository.kt
Outdated
Show resolved
Hide resolved
.../search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
.../search/src/main/java/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
...main/java/com/google/samples/apps/nowinandroid/feature/search/navigation/SearchNavigation.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt
Show resolved
Hide resolved
|
||
val newsResourcesFlow = newsResourceIds | ||
.mapLatest { it.toSet() } | ||
.distinctUntilChanged() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flatMapLatest {
newsResourceDao.getNewsResources(filterNewsIds = it)
}
val topicsFlow = topicIds
.mapLatest { it.toSet() }
.distinctUntilChanged()
.flatMapLatest(topicDao::getTopicEntities)
return combine(newsResourcesFlow, topicsFlow) { newsResources, topics ->
SearchResult(
topics = topics.map { it.asExternalModel() },
newsResources = newsResources.map { it.asExternalModel() },
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.distinctUntilChanged()
.flatMapLatest(topicDao::getTopicEntities)
return combine(newsResourcesFlow, topicsFlow) { newsResources, topics ->
SearchResult(
topics = topics.map { it.asExternalModel() },
newsResources = newsResources.map { it.asExternalModel() },
Adds search UI (same change as #656) - Empty search screen if the search result is empty - Topics contents that reuses the TopicsTabContent for InterestsScreen - Updates contents that reuses the newsFeed for ForYouScreen TODO: Needs to add RecentSearch Adds search backend that wires the backend data with the search UI - Add Fts related tables. - Add SearchContentsRepository that takes care of populating the Fts tables and search the contents from the Fts tables. - Wire the SearchContentsRepository with the SearchViewModel
Adds search UI (same change as #656)
TODO: Needs to add RecentSearch
Adds search backend that wires the backend data with the search UI
Screenshot:
![](https://user-images.githubusercontent.com/796361/232720145-ecb269fa-089b-4723-a17d-a408ec0ee24b.png)