manager: update app state upon app profile changes

properly update the superuser app list state after changes have been made to app profile
This commit is contained in:
Rifat Azad
2025-06-12 10:18:51 +06:00
parent f231cbdba7
commit 67759ad723
2 changed files with 8 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.dropUnlessResumed
import androidx.lifecycle.viewmodel.compose.viewModel
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.ramcosta.composedestinations.annotation.Destination
@@ -94,6 +95,7 @@ fun AppProfileScreen(
val snackBarHost = LocalSnackbarHost.current
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
val scope = rememberCoroutineScope()
val viewModel: SuperUserViewModel = viewModel()
val failToUpdateAppProfile = stringResource(R.string.failed_to_update_app_profile).format(appInfo.label)
val failToUpdateSepolicy = stringResource(R.string.failed_to_update_sepolicy).format(appInfo.label)
val suNotAllowed = stringResource(R.string.su_not_allowed).format(appInfo.label)
@@ -160,6 +162,7 @@ fun AppProfileScreen(
snackBarHost.showSnackbar(failToUpdateAppProfile.format(appInfo.uid))
} else {
profile = it
viewModel.updateAppProfile(packageName, it)
}
}
},

View File

@@ -91,6 +91,11 @@ class SuperUserViewModel : ViewModel() {
}
}
fun updateAppProfile(packageName: String, newProfile: Natives.Profile) {
apps = apps.map {
if (it.packageName == packageName) it.copy(profile = newProfile) else it
}
}
suspend fun fetchAppList() {
isRefreshing = true