use module dir name as real id

This commit is contained in:
5ec1cff
2025-01-26 23:54:32 +08:00
parent 35bf2f1dca
commit 7b39c295aa
2 changed files with 9 additions and 6 deletions

View File

@@ -411,7 +411,7 @@ private fun ModuleList(
val success = loadingDialog.withLoading { val success = loadingDialog.withLoading {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
uninstallModule(module.id) uninstallModule(module.dirId)
} }
} }
@@ -491,7 +491,7 @@ private fun ModuleList(
scope.launch { scope.launch {
val success = loadingDialog.withLoading { val success = loadingDialog.withLoading {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
toggleModule(module.id, !module.enabled) toggleModule(module.dirId, !module.enabled)
} }
} }
if (success) { if (success) {
@@ -522,7 +522,7 @@ private fun ModuleList(
} }
}, },
onClick = { onClick = {
onClickModule(it.id, it.name, it.hasWebUi) onClickModule(it.dirId, it.name, it.hasWebUi)
} }
) )
@@ -654,7 +654,7 @@ fun ModuleItem(
modifier = Modifier.defaultMinSize(52.dp, 32.dp), modifier = Modifier.defaultMinSize(52.dp, 32.dp),
enabled = !module.remove && module.enabled, enabled = !module.remove && module.enabled,
onClick = { onClick = {
navigator.navigate(ExecuteModuleActionScreenDestination(module.id)) navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
viewModel.markNeedRefresh() viewModel.markNeedRefresh()
}, },
contentPadding = ButtonDefaults.TextButtonContentPadding contentPadding = ButtonDefaults.TextButtonContentPadding
@@ -769,7 +769,8 @@ fun ModuleItemPreview() {
remove = false, remove = false,
updateJson = "", updateJson = "",
hasWebUi = false, hasWebUi = false,
hasActionScript = false hasActionScript = false,
dirId = "dirId"
) )
ModuleItem(EmptyDestinationsNavigator, module, "", {}, {}, {}, {}) ModuleItem(EmptyDestinationsNavigator, module, "", {}, {}, {}, {})
} }

View File

@@ -38,6 +38,7 @@ class ModuleViewModel : ViewModel() {
val updateJson: String, val updateJson: String,
val hasWebUi: Boolean, val hasWebUi: Boolean,
val hasActionScript: Boolean, val hasActionScript: Boolean,
val dirId: String, // real module id (dir name)
) )
data class ModuleUpdateInfo( data class ModuleUpdateInfo(
@@ -104,7 +105,8 @@ class ModuleViewModel : ViewModel() {
obj.getBoolean("remove"), obj.getBoolean("remove"),
obj.optString("updateJson"), obj.optString("updateJson"),
obj.optBoolean("web"), obj.optBoolean("web"),
obj.optBoolean("action") obj.optBoolean("action"),
obj.getString("dir_id"),
) )
}.toList() }.toList()
isNeedRefresh = false isNeedRefresh = false