Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Also show new patches in the removed patches dialog #2257

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "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": {
Expand Down
15 changes: 13 additions & 2 deletions lib/ui/views/patcher/patcher_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PatcherViewModel extends BaseViewModel {
BuildContext? ctx;
List<Patch> selectedPatches = [];
List<String> removedPatches = [];
List<String> newPatches = [];

void navigateToAppSelector() {
_navigationService.navigateTo(Routes.appSelectorView);
Expand Down Expand Up @@ -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'),
)
: '',
),
),
),
Expand Down Expand Up @@ -188,14 +194,14 @@ class PatcherViewModel extends BaseViewModel {
}
if (savedPatchNames.isEmpty) {
return false;
} else {
return !savedPatchNames.contains(patch.name);
}
return !savedPatchNames.contains(patch.name);
}

Future<void> loadLastSelectedPatches() async {
this.selectedPatches.clear();
removedPatches.clear();
newPatches.clear();
final List<String> selectedPatches =
await _managerAPI.getSelectedPatches(selectedApp!.packageName);
final List<Patch> patches =
Expand Down Expand Up @@ -236,6 +242,11 @@ class PatcherViewModel extends BaseViewModel {
}
}
}
for (final patch in patches) {
if (isPatchNew(patch)) {
newPatches.add('• ${patch.name}');
}
}
notifyListeners();
}
}