Add force refresh to get module list after installing a module

This commit is contained in:
ShirkNeko
2025-05-22 18:12:13 +08:00
parent b2ae20b796
commit f1f78d2485
4 changed files with 13 additions and 15 deletions

View File

@@ -47,6 +47,8 @@ import com.sukisu.ultra.ui.component.KeyEventBlocker
import com.sukisu.ultra.ui.util.*
import com.sukisu.ultra.R
import com.sukisu.ultra.ui.theme.CardConfig
import com.sukisu.ultra.ui.viewmodel.ModuleViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import java.io.File
import java.text.SimpleDateFormat
import java.util.*
@@ -109,6 +111,7 @@ fun FlashScreen(navigator: DestinationsNavigator, flashIt: FlashIt) {
val scope = rememberCoroutineScope()
val scrollState = rememberScrollState()
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
val viewModel: ModuleViewModel = viewModel()
val errorCodeString = stringResource(R.string.error_code)
val checkLogString = stringResource(R.string.check_log)
@@ -162,6 +165,7 @@ fun FlashScreen(navigator: DestinationsNavigator, flashIt: FlashIt) {
}
} else {
setFlashingStatus(FlashingStatus.SUCCESS)
viewModel.markNeedRefresh()
}
if (showReboot) {
text += "\n\n\n"
@@ -196,6 +200,8 @@ fun FlashScreen(navigator: DestinationsNavigator, flashIt: FlashIt) {
if (flashIt is FlashIt.FlashBoot) {
navigator.popBackStack()
} else {
viewModel.markNeedRefresh()
viewModel.fetchModuleList()
navigator.navigate(ModuleScreenDestination) {
}
}

View File

@@ -1,3 +1,5 @@
package com.sukisu.ultra.ui.screen
import androidx.compose.animation.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
@@ -514,9 +516,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
val profile = Natives.getAppProfile(app.packageName, app.uid)
val updatedProfile = profile.copy(allowSu = allowSu)
if (Natives.setAppProfile(updatedProfile)) {
// 不重新获取应用列表,避免滚动位置重置
// viewModel.fetchAppList()
// 仅更新当前应用的配置
viewModel.updateAppProfileLocally(app.packageName, updatedProfile)
}
}
@@ -556,9 +555,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
val profile = Natives.getAppProfile(app.packageName, app.uid)
val updatedProfile = profile.copy(allowSu = allowSu)
if (Natives.setAppProfile(updatedProfile)) {
// 不重新获取应用列表,避免滚动位置重置
// viewModel.fetchAppList()
// 仅更新当前应用的配置
viewModel.updateAppProfileLocally(app.packageName, updatedProfile)
}
}
@@ -598,9 +594,6 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
val profile = Natives.getAppProfile(app.packageName, app.uid)
val updatedProfile = profile.copy(allowSu = allowSu)
if (Natives.setAppProfile(updatedProfile)) {
// 不重新获取应用列表,避免滚动位置重置
// viewModel.fetchAppList()
// 仅更新当前应用的配置
viewModel.updateAppProfileLocally(app.packageName, updatedProfile)
}
}

View File

@@ -1,6 +1,5 @@
package com.sukisu.ultra.ui.screen
import LabelText
import android.content.ClipData
import android.content.ClipboardManager
import android.widget.Toast