mirror of
https://github.com/ivabus/gui
synced 2025-06-08 00:00:27 +03:00
test search
This commit is contained in:
parent
f54c5e4d44
commit
c6963c08d3
1 changed files with 4 additions and 6 deletions
|
@ -22,9 +22,8 @@
|
||||||
|
|
||||||
const searchLimit = 5;
|
const searchLimit = 5;
|
||||||
|
|
||||||
const setPackages = (pkgs: GUIPackage[]) => {
|
const setPackages = (pkgs: GUIPackage[], isSearch?: boolean) => {
|
||||||
console.log('pkgs sub', pkgs);
|
packages = isSearch ? pkgs : pkgs.sort((a, b) => {
|
||||||
packages = pkgs.sort((a, b) => {
|
|
||||||
if (sortBy === 'popularity') {
|
if (sortBy === 'popularity') {
|
||||||
const aPop = +a.dl_count + a.installs;
|
const aPop = +a.dl_count + a.installs;
|
||||||
const bPop = +b.dl_count + b.installs;
|
const bPop = +b.dl_count + b.installs;
|
||||||
|
@ -59,14 +58,13 @@
|
||||||
const onSearch = (term: string) => {
|
const onSearch = (term: string) => {
|
||||||
if (term !== '' && term.length > 1) {
|
if (term !== '' && term.length > 1) {
|
||||||
const res = packagesIndex.search(term);
|
const res = packagesIndex.search(term);
|
||||||
const matchingPackages = [];
|
const matchingPackages: GUIPackage[] = [];
|
||||||
for (let i = 0; i < searchLimit; i++) {
|
for (let i = 0; i < searchLimit; i++) {
|
||||||
if (res[i]) {
|
if (res[i]) {
|
||||||
matchingPackages.push(res[i].item);
|
matchingPackages.push(res[i].item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(res, matchingPackages)
|
setPackages(matchingPackages, true);
|
||||||
setPackages(matchingPackages);
|
|
||||||
} else {
|
} else {
|
||||||
setPackages(allPackages);
|
setPackages(allPackages);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue