mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 21:30:16 +02:00
Merge pull request #1228 from ImranR98/dev
Save Search Preferences (#1226)
This commit is contained in:
@@ -286,10 +286,14 @@ class AddAppPageState extends State<AddAppPage> {
|
|||||||
selectedByDefault: true,
|
selectedByDefault: true,
|
||||||
onlyOneSelectionAllowed: false,
|
onlyOneSelectionAllowed: false,
|
||||||
titlesAreLinks: false,
|
titlesAreLinks: false,
|
||||||
|
deselectThese: settingsProvider.searchDeselected,
|
||||||
);
|
);
|
||||||
}) ??
|
}) ??
|
||||||
[];
|
[];
|
||||||
if (searchSources.isNotEmpty) {
|
if (searchSources.isNotEmpty) {
|
||||||
|
settingsProvider.searchDeselected = sourceStrings.keys
|
||||||
|
.where((s) => !searchSources.contains(s))
|
||||||
|
.toList();
|
||||||
var results = await Future.wait(sourceProvider.sources
|
var results = await Future.wait(sourceProvider.sources
|
||||||
.where((e) => searchSources.contains(e.name))
|
.where((e) => searchSources.contains(e.name))
|
||||||
.map((e) async {
|
.map((e) async {
|
||||||
@@ -306,7 +310,6 @@ class AddAppPageState extends State<AddAppPage> {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// .then((results) async {
|
|
||||||
// Interleave results instead of simple reduce
|
// Interleave results instead of simple reduce
|
||||||
Map<String, List<String>> res = {};
|
Map<String, List<String>> res = {};
|
||||||
var si = 0;
|
var si = 0;
|
||||||
|
@@ -604,11 +604,13 @@ class SelectionModal extends StatefulWidget {
|
|||||||
this.selectedByDefault = true,
|
this.selectedByDefault = true,
|
||||||
this.onlyOneSelectionAllowed = false,
|
this.onlyOneSelectionAllowed = false,
|
||||||
this.titlesAreLinks = true,
|
this.titlesAreLinks = true,
|
||||||
this.title});
|
this.title,
|
||||||
|
this.deselectThese = const []});
|
||||||
|
|
||||||
String? title;
|
String? title;
|
||||||
Map<String, List<String>> entries;
|
Map<String, List<String>> entries;
|
||||||
bool selectedByDefault;
|
bool selectedByDefault;
|
||||||
|
List<String> deselectThese;
|
||||||
bool onlyOneSelectionAllowed;
|
bool onlyOneSelectionAllowed;
|
||||||
bool titlesAreLinks;
|
bool titlesAreLinks;
|
||||||
|
|
||||||
@@ -622,9 +624,13 @@ class _SelectionModalState extends State<SelectionModal> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
for (var url in widget.entries.entries) {
|
for (var entry in widget.entries.entries) {
|
||||||
entrySelections.putIfAbsent(url,
|
entrySelections.putIfAbsent(
|
||||||
() => widget.selectedByDefault && !widget.onlyOneSelectionAllowed);
|
entry,
|
||||||
|
() =>
|
||||||
|
widget.selectedByDefault &&
|
||||||
|
!widget.onlyOneSelectionAllowed &&
|
||||||
|
!widget.deselectThese.contains(entry.key));
|
||||||
}
|
}
|
||||||
if (widget.selectedByDefault && widget.onlyOneSelectionAllowed) {
|
if (widget.selectedByDefault && widget.onlyOneSelectionAllowed) {
|
||||||
selectOnlyOne(widget.entries.entries.first.key);
|
selectOnlyOne(widget.entries.entries.first.key);
|
||||||
|
@@ -446,4 +446,13 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
prefs?.setBool('parallelDownloads', val);
|
prefs?.setBool('parallelDownloads', val);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> get searchDeselected {
|
||||||
|
return prefs?.getStringList('searchDeselected') ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
set searchDeselected(List<String> list) {
|
||||||
|
prefs?.setStringList('searchDeselected', list);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user