Merge pull request #1228 from ImranR98/dev

Save Search Preferences (#1226)
This commit is contained in:
Imran
2023-12-31 23:42:22 -05:00
committed by GitHub
3 changed files with 23 additions and 5 deletions

View File

@@ -286,10 +286,14 @@ class AddAppPageState extends State<AddAppPage> {
selectedByDefault: true,
onlyOneSelectionAllowed: false,
titlesAreLinks: false,
deselectThese: settingsProvider.searchDeselected,
);
}) ??
[];
if (searchSources.isNotEmpty) {
settingsProvider.searchDeselected = sourceStrings.keys
.where((s) => !searchSources.contains(s))
.toList();
var results = await Future.wait(sourceProvider.sources
.where((e) => searchSources.contains(e.name))
.map((e) async {
@@ -306,7 +310,6 @@ class AddAppPageState extends State<AddAppPage> {
}
}));
// .then((results) async {
// Interleave results instead of simple reduce
Map<String, List<String>> res = {};
var si = 0;

View File

@@ -604,11 +604,13 @@ class SelectionModal extends StatefulWidget {
this.selectedByDefault = true,
this.onlyOneSelectionAllowed = false,
this.titlesAreLinks = true,
this.title});
this.title,
this.deselectThese = const []});
String? title;
Map<String, List<String>> entries;
bool selectedByDefault;
List<String> deselectThese;
bool onlyOneSelectionAllowed;
bool titlesAreLinks;
@@ -622,9 +624,13 @@ class _SelectionModalState extends State<SelectionModal> {
@override
void initState() {
super.initState();
for (var url in widget.entries.entries) {
entrySelections.putIfAbsent(url,
() => widget.selectedByDefault && !widget.onlyOneSelectionAllowed);
for (var entry in widget.entries.entries) {
entrySelections.putIfAbsent(
entry,
() =>
widget.selectedByDefault &&
!widget.onlyOneSelectionAllowed &&
!widget.deselectThese.contains(entry.key));
}
if (widget.selectedByDefault && widget.onlyOneSelectionAllowed) {
selectOnlyOne(widget.entries.entries.first.key);

View File

@@ -446,4 +446,13 @@ class SettingsProvider with ChangeNotifier {
prefs?.setBool('parallelDownloads', val);
notifyListeners();
}
List<String> get searchDeselected {
return prefs?.getStringList('searchDeselected') ?? [];
}
set searchDeselected(List<String> list) {
prefs?.setStringList('searchDeselected', list);
notifyListeners();
}
}