manager: Fallback allows developers to override user preferences for the selected WebUI engine
- Because the WebUI can cause some problems, the automatic fetching of the
This commit is contained in:
@@ -72,8 +72,6 @@ import com.sukisu.ultra.ui.theme.CardConfig.cardElevation
|
||||
import com.sukisu.ultra.ui.webui.WebUIXActivity
|
||||
import com.dergoogler.mmrl.platform.Platform
|
||||
import androidx.core.net.toUri
|
||||
import com.dergoogler.mmrl.platform.model.ModuleConfig
|
||||
import com.dergoogler.mmrl.platform.model.ModuleConfig.Companion.asModuleConfig
|
||||
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -384,19 +382,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
.putExtra("id", id)
|
||||
.putExtra("name", name)
|
||||
|
||||
val config = id.asModuleConfig
|
||||
val engine = config.getWebuiEngine(context)
|
||||
if (engine != null) {
|
||||
webUILauncher.launch(
|
||||
when (config.getWebuiEngine(context)) {
|
||||
"wx" -> wxEngine
|
||||
"ksu" -> ksuEngine
|
||||
else -> ksuEngine
|
||||
}
|
||||
)
|
||||
return@ModuleList
|
||||
}
|
||||
|
||||
webUILauncher.launch(
|
||||
if (prefs.getBoolean("use_webuix", true) && Platform.isAlive) {
|
||||
wxEngine
|
||||
@@ -917,8 +902,7 @@ fun ModuleItemPreview() {
|
||||
updateJson = "",
|
||||
hasWebUi = false,
|
||||
hasActionScript = false,
|
||||
dirId = "dirId",
|
||||
config = ModuleConfig()
|
||||
dirId = "dirId"
|
||||
)
|
||||
ModuleItem(EmptyDestinationsNavigator, module, "", {}, {}, {}, {})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import com.sukisu.ultra.ui.util.HanziToPinyin
|
||||
import com.sukisu.ultra.ui.util.listModules
|
||||
import org.json.JSONArray
|
||||
@@ -18,8 +17,6 @@ import org.json.JSONObject
|
||||
import java.text.Collator
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import com.dergoogler.mmrl.platform.model.ModuleConfig
|
||||
import com.dergoogler.mmrl.platform.model.ModuleConfig.Companion.asModuleConfig
|
||||
|
||||
class ModuleViewModel : ViewModel() {
|
||||
|
||||
@@ -43,7 +40,6 @@ class ModuleViewModel : ViewModel() {
|
||||
val hasWebUi: Boolean,
|
||||
val hasActionScript: Boolean,
|
||||
val dirId: String, // real module id (dir name)
|
||||
var config: ModuleConfig? = null,
|
||||
)
|
||||
|
||||
var isRefreshing by mutableStateOf(false)
|
||||
@@ -91,14 +87,13 @@ class ModuleViewModel : ViewModel() {
|
||||
.asSequence()
|
||||
.map { array.getJSONObject(it) }
|
||||
.map { obj ->
|
||||
val id = obj.getString("id")
|
||||
ModuleInfo(
|
||||
id,
|
||||
obj.optString("name", "Unknown"),
|
||||
obj.getString("id"),
|
||||
obj.optString("name"),
|
||||
obj.optString("author", "Unknown"),
|
||||
obj.optString("version", "Unknown"),
|
||||
obj.optInt("versionCode", 0),
|
||||
obj.optString("description", ""),
|
||||
obj.optString("description"),
|
||||
obj.getBoolean("enabled"),
|
||||
obj.getBoolean("update"),
|
||||
obj.getBoolean("remove"),
|
||||
@@ -108,19 +103,6 @@ class ModuleViewModel : ViewModel() {
|
||||
obj.getString("dir_id")
|
||||
)
|
||||
}.toList()
|
||||
launch {
|
||||
// load WebUI config
|
||||
modules.forEach { module ->
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
module.config = module.id.asModuleConfig
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Failed to load config for module ${module.id}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isNeedRefresh = false
|
||||
}.onFailure { e ->
|
||||
Log.e(TAG, "fetchModuleList: ", e)
|
||||
|
||||
Reference in New Issue
Block a user