Skip to content

Commit 7338157

Browse files
authored
fix: Patch process cancelation dialog conditions (#2554)
1 parent dd48011 commit 7338157

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

app/src/main/java/app/revanced/manager/ui/screen/PatcherScreen.kt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ fun PatcherScreen(
6262
onBackClick: () -> Unit,
6363
viewModel: PatcherViewModel
6464
) {
65+
fun onLeave() {
66+
viewModel.onBack()
67+
onBackClick()
68+
}
6569

6670
val context = LocalContext.current
6771
val exportApkLauncher =
@@ -72,7 +76,14 @@ fun PatcherScreen(
7276
var showInstallPicker by rememberSaveable { mutableStateOf(false) }
7377
var showDismissConfirmationDialog by rememberSaveable { mutableStateOf(false) }
7478

75-
BackHandler(onBack = { showDismissConfirmationDialog = true })
79+
fun onPageBack() {
80+
if(patcherSucceeded == null)
81+
showDismissConfirmationDialog = true
82+
else
83+
onLeave()
84+
}
85+
86+
BackHandler(onBack = ::onPageBack)
7687

7788
val steps by remember {
7889
derivedStateOf {
@@ -99,10 +110,7 @@ fun PatcherScreen(
99110
if (showDismissConfirmationDialog) {
100111
ConfirmDialog(
101112
onDismiss = { showDismissConfirmationDialog = false },
102-
onConfirm = {
103-
viewModel.onBack()
104-
onBackClick()
105-
},
113+
onConfirm = ::onLeave,
106114
title = stringResource(R.string.patcher_stop_confirm_title),
107115
description = stringResource(R.string.patcher_stop_confirm_description),
108116
icon = Icons.Outlined.Cancel
@@ -150,7 +158,7 @@ fun PatcherScreen(
150158
AppTopBar(
151159
title = stringResource(R.string.patcher),
152160
scrollBehavior = scrollBehavior,
153-
onBackClick = { showDismissConfirmationDialog = true }
161+
onBackClick = ::onPageBack
154162
)
155163
},
156164
bottomBar = {
@@ -229,4 +237,4 @@ fun PatcherScreen(
229237
}
230238
}
231239
}
232-
}
240+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ appcompat = "1.7.0"
99
preferences-datastore = "1.1.2"
1010
work-runtime = "2.10.1"
1111
compose-bom = "2025.05.00"
12-
navigation = "2.9.0"
12+
navigation = "2.8.6"
1313
accompanist = "0.37.0"
1414
placeholder = "1.1.2"
1515
reorderable = "2.4.3"

0 commit comments

Comments
 (0)