Skip to content

Commit

Permalink
fix: Use mutex for environment detection
Browse files Browse the repository at this point in the history
Change-Id: I3541593c4e45fc1c5c064cb872b5aa8980829097
  • Loading branch information
XayahSuSuSu committed Oct 4, 2023
1 parent 109ee7f commit c19e452
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ import com.xayah.databackup.util.command.PreparationUtil
import com.xayah.databackup.util.saveAppVersionName
import com.xayah.librootservice.util.withIOContext
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock

@ExperimentalMaterial3Api
@Composable
fun PageEnv(viewModel: GuideViewModel) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
val mutex = remember {
Mutex()
}
val contents = listOf(
stringResource(id = R.string.grant_root_access),
stringResource(id = R.string.release_prebuilt_binaries),
Expand Down Expand Up @@ -116,7 +121,9 @@ fun PageEnv(viewModel: GuideViewModel) {
state = states.value[it],
onClick = {
scope.launch {
onClicks[it]()
mutex.withLock {
onClicks[it]()
}
}
})
}
Expand Down

0 comments on commit c19e452

Please sign in to comment.