search: Use our custom httpClient with web helpers too
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -51,20 +51,14 @@ class SearchResultViewModel @Inject constructor(
|
|||||||
|
|
||||||
private val TAG = SearchResultViewModel::class.java.simpleName
|
private val TAG = SearchResultViewModel::class.java.simpleName
|
||||||
|
|
||||||
private val webSearchHelper: WebSearchHelper = WebSearchHelper()
|
|
||||||
private val searchHelper: SearchHelper = SearchHelper(authProvider.authData!!)
|
|
||||||
.using(httpClient)
|
|
||||||
|
|
||||||
val liveData: MutableLiveData<SearchBundle> = MutableLiveData()
|
val liveData: MutableLiveData<SearchBundle> = MutableLiveData()
|
||||||
|
|
||||||
private var searchBundle: SearchBundle = SearchBundle()
|
private var searchBundle: SearchBundle = SearchBundle()
|
||||||
|
|
||||||
fun helper(): SearchContract {
|
private val helper: SearchContract = if (authProvider.isAnonymous) {
|
||||||
return if (authProvider.isAnonymous) {
|
WebSearchHelper().using(httpClient)
|
||||||
webSearchHelper
|
} else {
|
||||||
} else {
|
SearchHelper(authProvider.authData!!).using(httpClient)
|
||||||
searchHelper
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun observeSearchResults(query: String) {
|
fun observeSearchResults(query: String) {
|
||||||
@@ -84,10 +78,8 @@ class SearchResultViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun search(
|
private fun search(query: String): SearchBundle {
|
||||||
query: String
|
return helper.searchResults(query)
|
||||||
): SearchBundle {
|
|
||||||
return helper().searchResults(query)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@@ -96,7 +88,7 @@ class SearchResultViewModel @Inject constructor(
|
|||||||
supervisorScope {
|
supervisorScope {
|
||||||
try {
|
try {
|
||||||
if (nextSubBundleSet.isNotEmpty()) {
|
if (nextSubBundleSet.isNotEmpty()) {
|
||||||
val newSearchBundle = helper().next(nextSubBundleSet)
|
val newSearchBundle = helper.next(nextSubBundleSet)
|
||||||
if (newSearchBundle.appList.isNotEmpty()) {
|
if (newSearchBundle.appList.isNotEmpty()) {
|
||||||
searchBundle.apply {
|
searchBundle.apply {
|
||||||
subBundles.flushAndAdd(newSearchBundle.subBundles)
|
subBundles.flushAndAdd(newSearchBundle.subBundles)
|
||||||
|
|||||||
@@ -44,18 +44,12 @@ class SearchSuggestionViewModel @Inject constructor(
|
|||||||
private val httpClient: IProxyHttpClient
|
private val httpClient: IProxyHttpClient
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
private val webSearchHelper: WebSearchHelper = WebSearchHelper()
|
|
||||||
private val searchHelper: SearchHelper = SearchHelper(authProvider.authData!!)
|
|
||||||
.using(httpClient)
|
|
||||||
|
|
||||||
val liveSearchSuggestions: MutableLiveData<List<SearchSuggestEntry>> = MutableLiveData()
|
val liveSearchSuggestions: MutableLiveData<List<SearchSuggestEntry>> = MutableLiveData()
|
||||||
|
|
||||||
fun helper(): SearchContract {
|
private val helper: SearchContract = if (authProvider.isAnonymous) {
|
||||||
return if (authProvider.isAnonymous) {
|
WebSearchHelper().using(httpClient)
|
||||||
webSearchHelper
|
} else {
|
||||||
} else {
|
SearchHelper(authProvider.authData!!).using(httpClient)
|
||||||
searchHelper
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun observeStreamBundles(query: String) {
|
fun observeStreamBundles(query: String) {
|
||||||
@@ -64,9 +58,7 @@ class SearchSuggestionViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSearchSuggestions(
|
private fun getSearchSuggestions(query: String): List<SearchSuggestEntry> {
|
||||||
query: String
|
return helper.searchSuggestions(query)
|
||||||
): List<SearchSuggestEntry> {
|
|
||||||
return helper().searchSuggestions(query)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user