mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-04-25 01:10:51 -04:00
Merge branch 'dev'
This commit is contained in:
@@ -46,9 +46,8 @@ class StreamViewModel @Inject constructor(
|
||||
|
||||
private var stash: HomeStash = mutableMapOf()
|
||||
|
||||
fun contract(): StreamContract {
|
||||
return webStreamHelper
|
||||
}
|
||||
private val streamContract: StreamContract
|
||||
get() = webStreamHelper
|
||||
|
||||
fun getStreamBundle(category: StreamContract.Category, type: StreamContract.Type) {
|
||||
liveData.postValue(ViewState.Loading)
|
||||
@@ -68,12 +67,12 @@ class StreamViewModel @Inject constructor(
|
||||
|
||||
//Fetch new stream bundle
|
||||
val newBundle = if (bundle.hasCluster()) {
|
||||
contract().nextStreamBundle(
|
||||
streamContract.nextStreamBundle(
|
||||
category,
|
||||
bundle.streamNextPageUrl
|
||||
)
|
||||
} else {
|
||||
contract().fetch(type, category)
|
||||
streamContract.fetch(type, category)
|
||||
}
|
||||
|
||||
//Update old bundle
|
||||
@@ -100,7 +99,7 @@ class StreamViewModel @Inject constructor(
|
||||
try {
|
||||
if (streamCluster.hasNext()) {
|
||||
val newCluster =
|
||||
contract().nextStreamCluster(streamCluster.clusterNextPageUrl)
|
||||
streamContract.nextStreamCluster(streamCluster.clusterNextPageUrl)
|
||||
updateCluster(category, streamCluster.id, newCluster)
|
||||
liveData.postValue(ViewState.Success(stash))
|
||||
} else {
|
||||
|
||||
@@ -39,9 +39,9 @@ import javax.inject.Inject
|
||||
@HiltViewModel
|
||||
class SearchResultViewModel @Inject constructor(
|
||||
val filterProvider: FilterProvider,
|
||||
authProvider: AuthProvider,
|
||||
searchHelper: SearchHelper,
|
||||
webSearchHelper: WebSearchHelper
|
||||
private val authProvider: AuthProvider,
|
||||
private val searchHelper: SearchHelper,
|
||||
private val webSearchHelper: WebSearchHelper
|
||||
) : ViewModel() {
|
||||
|
||||
private val TAG = SearchResultViewModel::class.java.simpleName
|
||||
@@ -50,11 +50,8 @@ class SearchResultViewModel @Inject constructor(
|
||||
|
||||
private var searchBundle: SearchBundle = SearchBundle()
|
||||
|
||||
private val helper: SearchContract = if (authProvider.isAnonymous) {
|
||||
webSearchHelper
|
||||
} else {
|
||||
searchHelper
|
||||
}
|
||||
private val helper: SearchContract
|
||||
get() = if (authProvider.isAnonymous) webSearchHelper else searchHelper
|
||||
|
||||
fun observeSearchResults(query: String) {
|
||||
//Clear old results
|
||||
|
||||
@@ -35,19 +35,16 @@ import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class SearchSuggestionViewModel @Inject constructor(
|
||||
authProvider: AuthProvider,
|
||||
searchHelper: SearchHelper,
|
||||
webSearchHelper: WebSearchHelper
|
||||
private val authProvider: AuthProvider,
|
||||
private val searchHelper: SearchHelper,
|
||||
private val webSearchHelper: WebSearchHelper
|
||||
) : ViewModel() {
|
||||
|
||||
private val _searchSuggestions = MutableStateFlow<List<SearchSuggestEntry>>(emptyList())
|
||||
val searchSuggestions = _searchSuggestions.asStateFlow()
|
||||
|
||||
private val helper: SearchContract = if (authProvider.isAnonymous) {
|
||||
webSearchHelper
|
||||
} else {
|
||||
searchHelper
|
||||
}
|
||||
private val helper: SearchContract
|
||||
get() = if (authProvider.isAnonymous) webSearchHelper else searchHelper
|
||||
|
||||
fun observeStreamBundles(query: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
||||
@@ -46,9 +46,8 @@ class CategoryStreamViewModel @Inject constructor(
|
||||
|
||||
private var stash: MutableMap<String, StreamBundle> = mutableMapOf()
|
||||
|
||||
fun contract(): CategoryStreamContract {
|
||||
return webCategoryStreamHelper
|
||||
}
|
||||
private val categoryStreamContract: CategoryStreamContract
|
||||
get() = webCategoryStreamHelper
|
||||
|
||||
fun getStreamBundle(category: StreamContract.Category) {
|
||||
liveData.postValue(ViewState.Loading)
|
||||
@@ -69,9 +68,9 @@ class CategoryStreamViewModel @Inject constructor(
|
||||
|
||||
//Fetch new stream bundle
|
||||
val newBundle = if (bundle.streamClusters.isEmpty()) {
|
||||
contract().fetch(category.value)
|
||||
categoryStreamContract.fetch(category.value)
|
||||
} else {
|
||||
contract().nextStreamBundle(
|
||||
categoryStreamContract.nextStreamBundle(
|
||||
category,
|
||||
bundle.streamNextPageUrl
|
||||
)
|
||||
@@ -101,7 +100,7 @@ class CategoryStreamViewModel @Inject constructor(
|
||||
try {
|
||||
if (streamCluster.hasNext()) {
|
||||
val newCluster =
|
||||
contract().nextStreamCluster(streamCluster.clusterNextPageUrl)
|
||||
categoryStreamContract.nextStreamCluster(streamCluster.clusterNextPageUrl)
|
||||
updateCluster(category, streamCluster.id, newCluster)
|
||||
liveData.postValue(ViewState.Success(stash))
|
||||
} else {
|
||||
|
||||
@@ -42,9 +42,8 @@ class TopChartViewModel @Inject constructor(
|
||||
|
||||
val liveData: MutableLiveData<ViewState> = MutableLiveData()
|
||||
|
||||
private fun contract(): TopChartsContract {
|
||||
return webTopChartsHelper
|
||||
}
|
||||
private val topChartsContract: TopChartsContract
|
||||
get() = webTopChartsHelper
|
||||
|
||||
fun getStreamCluster(type: TopChartsContract.Type, chart: TopChartsContract.Chart) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
@@ -53,7 +52,7 @@ class TopChartViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
try {
|
||||
val cluster = contract().getCluster(type.value, chart.value)
|
||||
val cluster = topChartsContract.getCluster(type.value, chart.value)
|
||||
updateCluster(type, chart, cluster)
|
||||
liveData.postValue(ViewState.Success(stash))
|
||||
} catch (_: Exception) {
|
||||
@@ -67,7 +66,7 @@ class TopChartViewModel @Inject constructor(
|
||||
try {
|
||||
val target = targetCluster(type, chart)
|
||||
if (target.hasNext()) {
|
||||
val newCluster = contract().getNextStreamCluster(
|
||||
val newCluster = topChartsContract.getNextStreamCluster(
|
||||
target.clusterNextPageUrl
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user