Skip to content

Commit

Permalink
manager: Optimize code
Browse files Browse the repository at this point in the history
- If action button pressed, we mark it as needRefresh
- Revert changes on ExecuteModuleAction.kt

Signed-off-by: rsuntk <rissu.ntk@gmail.com>
  • Loading branch information
rsuntk committed Nov 11, 2024
1 parent aeae99d commit 630ca31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.key
Expand All @@ -41,7 +40,6 @@ import me.weishu.kernelsu.R
import me.weishu.kernelsu.ui.component.KeyEventBlocker
import me.weishu.kernelsu.ui.util.LocalSnackbarHost
import me.weishu.kernelsu.ui.util.runModuleAction
import me.weishu.kernelsu.ui.viewmodel.ModuleViewModel
import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -76,19 +74,13 @@ fun ExecuteModuleActionScreen(navigator: DestinationsNavigator, moduleId: String
actionResult = it
}
}
if (actionResult) {
viewModel.fetchModuleList()
navigator.popBackStack()
} else {
viewModel.fetchModuleList()
}
if (actionResult) navigator.popBackStack()
}

Scaffold(
topBar = {
TopBar(
onBack = {
viewModel.fetchModuleList()
navigator.popBackStack()
},
onSave = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ fun ModuleItem(
val textDecoration = if (!module.remove) null else TextDecoration.LineThrough
val interactionSource = remember { MutableInteractionSource() }
val indication = LocalIndication.current
val viewModel = viewModel<ModuleViewModel>()

Column(
modifier = Modifier
Expand Down Expand Up @@ -580,7 +581,10 @@ fun ModuleItem(
if (module.hasActionScript) {
FilledTonalButton(
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
onClick = { navigator.navigate(ExecuteModuleActionScreenDestination(module.id)) },
onClick = {
navigator.navigate(ExecuteModuleActionScreenDestination(module.id))
viewModel.markNeedRefresh()
},
contentPadding = ButtonDefaults.TextButtonContentPadding
) {
Icon(
Expand Down

0 comments on commit 630ca31

Please sign in to comment.