mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
fix: experimental/universal patches being used even when turned off (#1090)
Co-authored-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
parent
5346f6e1bf
commit
5abcc7191f
@ -11,6 +11,7 @@ import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/services/patcher_api.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||
import 'package:revanced_manager/utils/about_info.dart';
|
||||
import 'package:revanced_manager/utils/check_for_supported_patch.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
@ -156,6 +157,14 @@ class PatcherViewModel extends BaseViewModel {
|
||||
this
|
||||
.selectedPatches
|
||||
.addAll(patches.where((patch) => selectedPatches.contains(patch.name)));
|
||||
if (!_managerAPI.areExperimentalPatchesEnabled()) {
|
||||
this.selectedPatches.removeWhere((patch) => !isPatchSupported(patch));
|
||||
}
|
||||
if (!_managerAPI.areUniversalPatchesEnabled()) {
|
||||
this
|
||||
.selectedPatches
|
||||
.removeWhere((patch) => patch.compatiblePackages.isEmpty);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/services/toast.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_experimental_patches.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||
|
||||
@ -126,12 +125,6 @@ class _PatchItemState extends State<PatchItem> {
|
||||
} else {
|
||||
widget.isSelected = newValue!;
|
||||
}
|
||||
if (widget.isUnsupported &&
|
||||
widget.isSelected &&
|
||||
!selectedUnsupportedPatches
|
||||
.contains(widget.name)) {
|
||||
selectedUnsupportedPatches.add(widget.name);
|
||||
}
|
||||
});
|
||||
widget.onChanged(widget.isSelected);
|
||||
},
|
||||
|
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:revanced_manager/utils/check_for_supported_patch.dart';
|
||||
|
||||
class SExperimentalPatches extends StatefulWidget {
|
||||
const SExperimentalPatches({super.key});
|
||||
@ -11,7 +13,8 @@ class SExperimentalPatches extends StatefulWidget {
|
||||
}
|
||||
|
||||
final _settingsViewModel = SettingsViewModel();
|
||||
final List<String> selectedUnsupportedPatches = [];
|
||||
final _patchesSelectorViewModel = PatchesSelectorViewModel();
|
||||
final _patcherViewModel = PatcherViewModel();
|
||||
|
||||
class _SExperimentalPatchesState extends State<SExperimentalPatches> {
|
||||
@override
|
||||
@ -35,12 +38,10 @@ class _SExperimentalPatchesState extends State<SExperimentalPatches> {
|
||||
_settingsViewModel.useExperimentalPatches(value);
|
||||
});
|
||||
if (!value) {
|
||||
for (final patch in selectedUnsupportedPatches) {
|
||||
PatchesSelectorViewModel()
|
||||
.selectedPatches
|
||||
.removeWhere((element) => patch == element.name);
|
||||
}
|
||||
selectedUnsupportedPatches.clear();
|
||||
_patcherViewModel.selectedPatches
|
||||
.removeWhere((patch) => !isPatchSupported(patch));
|
||||
_patchesSelectorViewModel.selectedPatches
|
||||
.removeWhere((patch) => !isPatchSupported(patch));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
||||
|
||||
class SExperimentalUniversalPatches extends StatefulWidget {
|
||||
const SExperimentalUniversalPatches({super.key});
|
||||
|
||||
@ -11,6 +14,8 @@ class SExperimentalUniversalPatches extends StatefulWidget {
|
||||
}
|
||||
|
||||
final _settingsViewModel = SettingsViewModel();
|
||||
final _patchesSelectorViewModel = PatchesSelectorViewModel();
|
||||
final _patcherViewModel = PatcherViewModel();
|
||||
|
||||
class _SExperimentalUniversalPatchesState
|
||||
extends State<SExperimentalUniversalPatches> {
|
||||
@ -34,6 +39,12 @@ class _SExperimentalUniversalPatchesState
|
||||
setState(() {
|
||||
_settingsViewModel.showUniversalPatches(value);
|
||||
});
|
||||
if (!value) {
|
||||
_patcherViewModel.selectedPatches
|
||||
.removeWhere((patch) => patch.compatiblePackages.isEmpty);
|
||||
_patchesSelectorViewModel.selectedPatches
|
||||
.removeWhere((patch) => patch.compatiblePackages.isEmpty);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user