@@ -648,15 +648,14 @@ class DictionarySearchWidgetState extends State<DictionarySearchWidget>
648
648
deconjugated.remove (queryKana);
649
649
deconjugated.remove (query);
650
650
}
651
+ deconjugated.removeWhere ((e) => e.isEmpty);
651
652
652
653
// if the search query was changed show a snackbar and give the option to
653
654
// use the original search
654
655
if (queryKana != query || deconjugated.isNotEmpty){
655
656
656
657
deconjugationFlushbar = DictionaryAltSearchFlushbar (
657
- query,
658
- queryKana != query ? queryKana : null ,
659
- deconjugated,
658
+ selectedSortPrioritiesToActualQueries (query, queryKana, deconjugated),
660
659
onAltSearchTapped
661
660
)
662
661
.build (context)..show (context).then ((value) {
@@ -672,25 +671,7 @@ class DictionarySearchWidgetState extends State<DictionarySearchWidget>
672
671
widget.context.read <DictSearch >().currentAlternativeSearches = deconjugated;
673
672
widget.context.read <DictSearch >().searchResults =
674
673
await GetIt .I <DictionarySearch >().search (
675
- query,
676
- () {
677
- List <String > allQueries = [];
678
-
679
- List <String > sel = context.read <Settings >().dictionary.selectedSearchResultSortPriorities;
680
- for (var i = 0 ; i < sel.length; i++ ) {
681
- if (sel[i] == LocaleKeys .SettingsScreen_dict_term ){
682
- allQueries.add (query);
683
- }
684
- else if (sel[i] == LocaleKeys .SettingsScreen_dict_convert_to_kana && queryKana != null ){
685
- allQueries.add (queryKana);
686
- }
687
- else if (sel[i] == LocaleKeys .SettingsScreen_dict_base_form ){
688
- allQueries.addAll (deconjugated);
689
- }
690
- }
691
-
692
- return allQueries;
693
- } ()
674
+ query, selectedSortPrioritiesToActualQueries (query, queryKana, deconjugated)
694
675
) ?? [];
695
676
}
696
677
@@ -702,5 +683,30 @@ class DictionarySearchWidgetState extends State<DictionarySearchWidget>
702
683
deconjugationFlushbar? .dismiss ();
703
684
704
685
}
686
+
687
+ /// Based on the selected search result sort priorities, returns a list of
688
+ /// the actual search terms following the user'spriorities
689
+ List <String > selectedSortPrioritiesToActualQueries (
690
+ String query, String ? queryKana, List <String > deconjugated
691
+ ){
692
+
693
+ List <String > allQueries = [];
694
+
695
+ List <String > sel = context.read <Settings >().dictionary.selectedSearchResultSortPriorities;
696
+ for (var i = 0 ; i < sel.length; i++ ) {
697
+ if (sel[i] == LocaleKeys .SettingsScreen_dict_term ){
698
+ allQueries.add (query);
699
+ }
700
+ else if (sel[i] == LocaleKeys .SettingsScreen_dict_convert_to_kana && queryKana != null ){
701
+ allQueries.add (queryKana);
702
+ }
703
+ else if (sel[i] == LocaleKeys .SettingsScreen_dict_base_form ){
704
+ allQueries.addAll (deconjugated);
705
+ }
706
+ }
707
+
708
+ return allQueries;
709
+
710
+ }
705
711
}
706
712
0 commit comments