Fix selecting random api

This commit is contained in:
Blatzar 2022-10-07 00:06:14 +02:00
parent 601f4c5a77
commit 4c4b6b1787

View file

@ -276,9 +276,6 @@ class HomeViewModel : ViewModel() {
if (preferredApiName == noneApi.name) { if (preferredApiName == noneApi.name) {
setKey(USER_SELECTED_HOMEPAGE_API, noneApi.name) setKey(USER_SELECTED_HOMEPAGE_API, noneApi.name)
loadAndCancel(noneApi) loadAndCancel(noneApi)
// If the plugin isn't loaded yet. (Does not set the key)
} else if (api == null) {
loadAndCancel(noneApi)
} else if (preferredApiName == randomApi.name) { } else if (preferredApiName == randomApi.name) {
val validAPIs = context?.filterProviderByPreferredMedia() val validAPIs = context?.filterProviderByPreferredMedia()
if (validAPIs.isNullOrEmpty()) { if (validAPIs.isNullOrEmpty()) {
@ -289,6 +286,9 @@ class HomeViewModel : ViewModel() {
loadAndCancel(apiRandom) loadAndCancel(apiRandom)
setKey(USER_SELECTED_HOMEPAGE_API, apiRandom.name) setKey(USER_SELECTED_HOMEPAGE_API, apiRandom.name)
} }
// If the plugin isn't loaded yet. (Does not set the key)
} else if (api == null) {
loadAndCancel(noneApi)
} else { } else {
setKey(USER_SELECTED_HOMEPAGE_API, api.name) setKey(USER_SELECTED_HOMEPAGE_API, api.name)
loadAndCancel(api) loadAndCancel(api)