Skip to content

Commit

Permalink
fix: patch options reset button being broken
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelen123 committed Jan 21, 2024
1 parent 4acef77 commit 0b9889e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
var selectionWarningEnabled by mutableStateOf(true)
private set

val allowIncompatiblePatches = get<PreferencesManager>().disablePatchVersionCompatCheck.getBlocking()
val allowIncompatiblePatches =
get<PreferencesManager>().disablePatchVersionCompatCheck.getBlocking()
val bundlesFlow =
get<PatchBundleRepository>().bundleInfoFlow(packageName, input.app.version)

Expand All @@ -63,7 +64,8 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
return@launch
}

fun BundleInfo.hasDefaultPatches() = patchSequence(allowIncompatiblePatches).any { it.include }
fun BundleInfo.hasDefaultPatches() =
patchSequence(allowIncompatiblePatches).any { it.include }

// Don't show the warning if there are no default patches.
selectionWarningEnabled = bundlesFlow.first().any(BundleInfo::hasDefaultPatches)
Expand Down Expand Up @@ -179,7 +181,8 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
}

fun resetOptions(bundle: Int, patch: PatchInfo) {
patchOptions[bundle]?.remove(patch.name)
app.toast(app.getString(R.string.patch_options_reset_toast))
patchOptions[bundle] = patchOptions[bundle]?.remove(patch.name) ?: return
}

fun dismissDialogs() {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
<string name="unsupported_patches">Unsupported patches</string>
<string name="universal_patches">Universal patches</string>
<string name="patch_selection_reset_toast">Patch selection and options has been reset to recommended defaults</string>
<string name="patch_options_reset_toast">Patch options have been reset</string>
<string name="selection_warning_title">Stop using defaults?</string>
<string name="selection_warning_description">You may encounter issues when not using the default patch selection and options.</string>
<string name="selection_warning_continue_countdown">Continue (%ds)</string>
Expand Down

0 comments on commit 0b9889e

Please sign in to comment.