Move exact matches of searched categories to the top (#379)
This commit is contained in:
parent
c022db9c20
commit
5a374f74bc
1 changed files with 10 additions and 0 deletions
|
|
@ -83,6 +83,16 @@ abstract class SearchStoreBase with Store {
|
||||||
query: query,
|
query: query,
|
||||||
headers: authStore.headersTwitch,
|
headers: authStore.headersTwitch,
|
||||||
)
|
)
|
||||||
|
.then((categories) {
|
||||||
|
// Move exact matches to the first result
|
||||||
|
final matchingIndex = categories.data
|
||||||
|
.indexWhere((c) => c.name.toLowerCase() == query.toLowerCase());
|
||||||
|
if (matchingIndex >= 1) {
|
||||||
|
final matchingCategory = categories.data.removeAt(matchingIndex);
|
||||||
|
categories.data.insert(0, matchingCategory);
|
||||||
|
}
|
||||||
|
return categories;
|
||||||
|
})
|
||||||
.asObservable();
|
.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue