diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt index a0b02883a0e4c23f931bc186a8d9b067ca9ba26d..5e2a519ab519e5b30f0a9847cf53eadbd5487118 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt @@ -140,6 +140,11 @@ class SearchFragment : if (!requireContext().isNetworkAvailable()) { return } + + if (authObjects.value?.none { it is AuthObject.GPlayAuth } == true) { + return + } + searchViewModel.loadMore(searchText) } } diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt index a2bc710807f7e60f1d9d0e8e69d45bbf02b466b8..dbf0b1ba968b7f90a4861ecc74fe1e05d5192228 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt @@ -91,7 +91,7 @@ class SearchViewModel @Inject constructor( } successAuthList.find { it is AuthObject.CleanApk }?.run { - getSearchResults(query, AuthData("", ""), lifecycleOwner) + getSearchResults(query, null, lifecycleOwner) return@onLoadData } }, retryBlock) @@ -105,17 +105,20 @@ class SearchViewModel @Inject constructor( */ private fun getSearchResults( query: String, - authData: AuthData, + authData: AuthData?, lifecycleOwner: LifecycleOwner ) { viewModelScope.launch(Dispatchers.IO) { - val searchResultSupreme = fusedAPIRepository.getCleanApkSearchResults(query, authData) + val searchResultSupreme = fusedAPIRepository.getCleanApkSearchResults( + query, + authData ?: AuthData("", "") + ) searchResult.postValue(searchResultSupreme) if (!searchResultSupreme.isSuccess()) { val exception = - if (authData.aasToken.isNotBlank() || authData.authToken.isNotBlank()) { + if (authData != null) { GPlayException( searchResultSupreme.isTimeout(), searchResultSupreme.message.ifBlank { DATA_LOAD_ERROR } @@ -130,6 +133,10 @@ class SearchViewModel @Inject constructor( handleException(exception) } + if (authData == null) { + return@launch + } + nextSubBundle = null fetchGplayData(query) }