File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -682,6 +682,8 @@ function refreshLibrary(options) {
682
682
Utils . searchRelevance ( app . description , searchValue ) / 5 + // match on description, but pay less attention
683
683
( ( app . tags && app . tags . includes ( searchValue ) ) ?10 :0 )
684
684
} ) ) ;
685
+ } else {
686
+ console . warn ( "Unknown search type " + searchType , searchValue ) ;
685
687
}
686
688
// Now finally, filter, sort based on relevance and set the search result
687
689
visibleApps = searchResult . filter ( a => a . relevance > 0 ) . sort ( ( a , b ) => ( b . relevance - ( 0 | b . sortorder ) ) - ( a . relevance - ( 0 | a . sortorder ) ) ) . map ( a => a . app ) ;
@@ -690,11 +692,12 @@ function refreshLibrary(options) {
690
692
if ( ! sortedByRelevance )
691
693
visibleApps . sort ( appSorter ) ;
692
694
693
- if ( activeSort ) {
695
+ if ( activeSort && ! searchValue ) { // only sort if not searching (searching already sorts)
694
696
if ( [ "created" , "modified" , "installs" , "favourites" ] . includes ( activeSort ) ) {
695
- visibleApps = visibleApps . sort ( ( a , b ) =>
697
+ visibleApps = visibleApps . sort ( ( a , b ) => {
696
698
( ( appSortInfo [ b . id ] || { } ) [ activeSort ] || 0 ) -
697
699
( ( appSortInfo [ a . id ] || { } ) [ activeSort ] || 0 ) ) ;
700
+ } ) ;
698
701
} else throw new Error ( "Unknown sort type " + activeSort ) ;
699
702
}
700
703
Original file line number Diff line number Diff line change @@ -338,6 +338,7 @@ function searchRelevance(value, searchString) {
338
338
let partRelevance = 0 ;
339
339
let valueParts = value . split ( / [ \s ( ) , . - ] / ) . filter ( p => p . length ) ;
340
340
searchString . split ( / [ \s - ( ) , . - ] / ) . forEach ( search => {
341
+ if ( search === "" ) return ; // ignore empty search strings
341
342
valueParts . forEach ( v => {
342
343
if ( v == search )
343
344
partRelevance += 20 ; // if a complete match, +20
You can’t perform that action at this time.
0 commit comments