fix: patch options reset button being broken

This commit is contained in:
Ax333l 2024-01-21 14:24:39 +01:00
parent 4acef776b2
commit 0b9889ea44
No known key found for this signature in database
GPG Key ID: D2B4D85271127D23
2 changed files with 7 additions and 3 deletions

View File

@ -52,7 +52,8 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
var selectionWarningEnabled by mutableStateOf(true) var selectionWarningEnabled by mutableStateOf(true)
private set private set
val allowIncompatiblePatches = get<PreferencesManager>().disablePatchVersionCompatCheck.getBlocking() val allowIncompatiblePatches =
get<PreferencesManager>().disablePatchVersionCompatCheck.getBlocking()
val bundlesFlow = val bundlesFlow =
get<PatchBundleRepository>().bundleInfoFlow(packageName, input.app.version) get<PatchBundleRepository>().bundleInfoFlow(packageName, input.app.version)
@ -63,7 +64,8 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
return@launch 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. // Don't show the warning if there are no default patches.
selectionWarningEnabled = bundlesFlow.first().any(BundleInfo::hasDefaultPatches) selectionWarningEnabled = bundlesFlow.first().any(BundleInfo::hasDefaultPatches)
@ -179,7 +181,8 @@ class PatchesSelectorViewModel(input: Params) : ViewModel(), KoinComponent {
} }
fun resetOptions(bundle: Int, patch: PatchInfo) { 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() { fun dismissDialogs() {

View File

@ -166,6 +166,7 @@
<string name="unsupported_patches">Unsupported patches</string> <string name="unsupported_patches">Unsupported patches</string>
<string name="universal_patches">Universal 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_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_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_description">You may encounter issues when not using the default patch selection and options.</string>
<string name="selection_warning_continue_countdown">Continue (%ds)</string> <string name="selection_warning_continue_countdown">Continue (%ds)</string>