From 7f7c585468a32f862bbc7c259900344968f1f4c9 Mon Sep 17 00:00:00 2001 From: aAbed Date: Sat, 12 Oct 2024 11:22:08 +0545 Subject: [PATCH 1/3] feat: Also show new patches in the removed patches dialog --- assets/i18n/strings.i18n.json | 3 ++- lib/ui/views/patcher/patcher_viewmodel.dart | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/assets/i18n/strings.i18n.json b/assets/i18n/strings.i18n.json index 3646947840..2ed2c38c8e 100755 --- a/assets/i18n/strings.i18n.json +++ b/assets/i18n/strings.i18n.json @@ -55,7 +55,8 @@ "widgetTitle": "Patcher", "patchButton": "Patch", "incompatibleArchWarningDialogText": "Patching on this architecture is not yet supported and might fail. Continue anyways?", - "removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n${patches}\n\nContinue anyways?", + "removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n${patches}\n\n${newPatches}Continue anyways?", + "addedPatchesDialogText": "The following patches have been added since the last time you patched this app.\n\n${addedPatches}\n\n", "requiredOptionDialogText": "Some patch options have to be set." }, "appSelectorCard": { diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index 68d86520b3..b8ba968634 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -28,6 +28,7 @@ class PatcherViewModel extends BaseViewModel { BuildContext? ctx; List selectedPatches = []; List removedPatches = []; + List newPatches = []; void navigateToAppSelector() { _navigationService.navigateTo(Routes.appSelectorView); @@ -59,6 +60,11 @@ class PatcherViewModel extends BaseViewModel { child: Text( t.patcherView.removedPatchesWarningDialogText( patches: removedPatches.join('\n'), + newPatches: newPatches.isNotEmpty + ? t.patcherView.addedPatchesDialogText( + addedPatches: newPatches.join('\n'), + ) + : '', ), ), ), @@ -186,16 +192,19 @@ class PatcherViewModel extends BaseViewModel { .map((p) => p.name) .toSet(); } - if (savedPatchNames.isEmpty) { - return false; - } else { - return !savedPatchNames.contains(patch.name); + if (!savedPatchNames.contains(patch.name)) { + if (!newPatches.contains('• ${patch.name}')) { + newPatches.add('• ${patch.name}'); + } + return true; } + return false; } Future loadLastSelectedPatches() async { this.selectedPatches.clear(); removedPatches.clear(); + newPatches.clear(); final List selectedPatches = await _managerAPI.getSelectedPatches(selectedApp!.packageName); final List patches = From 95f1d0d1ee06a081f0b7a2539b2286a369ac452d Mon Sep 17 00:00:00 2001 From: aAbed Date: Wed, 16 Oct 2024 10:57:58 +0545 Subject: [PATCH 2/3] fix: detect new patches immediately after selecting an app --- lib/ui/views/patcher/patcher_viewmodel.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index b8ba968634..02d4d70f63 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -192,13 +192,10 @@ class PatcherViewModel extends BaseViewModel { .map((p) => p.name) .toSet(); } - if (!savedPatchNames.contains(patch.name)) { - if (!newPatches.contains('• ${patch.name}')) { - newPatches.add('• ${patch.name}'); - } - return true; + if (savedPatchNames.isEmpty) { + return false; } - return false; + return !savedPatchNames.contains(patch.name); } Future loadLastSelectedPatches() async { @@ -245,6 +242,11 @@ class PatcherViewModel extends BaseViewModel { } } } + for (final patch in patches) { + if (isPatchNew(patch)) { + newPatches.add('• ${patch.name}'); + } + } notifyListeners(); } } From cf97bf36322772ea27e25593464266f592f504d2 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 17 Oct 2024 17:44:10 +0200 Subject: [PATCH 3/3] Apply suggestions from code review --- assets/i18n/strings.i18n.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/i18n/strings.i18n.json b/assets/i18n/strings.i18n.json index 2ed2c38c8e..63af9768a0 100755 --- a/assets/i18n/strings.i18n.json +++ b/assets/i18n/strings.i18n.json @@ -55,8 +55,8 @@ "widgetTitle": "Patcher", "patchButton": "Patch", "incompatibleArchWarningDialogText": "Patching on this architecture is not yet supported and might fail. Continue anyways?", - "removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n${patches}\n\n${newPatches}Continue anyways?", - "addedPatchesDialogText": "The following patches have been added since the last time you patched this app.\n\n${addedPatches}\n\n", + "removedPatchesWarningDialogText": "Removed patches since the last time you used them:\n\n${patches}\n\n${newPatches}Continue anyways?", + "addedPatchesDialogText": "Added patches since the last time you used them:\n\n${addedPatches}\n\n", "requiredOptionDialogText": "Some patch options have to be set." }, "appSelectorCard": {