This commit is contained in:
neil 2022-12-02 16:06:23 +08:00
parent c6963c08d3
commit 8531041a23

View file

@ -23,18 +23,20 @@
const searchLimit = 5; const searchLimit = 5;
const setPackages = (pkgs: GUIPackage[], isSearch?: boolean) => { const setPackages = (pkgs: GUIPackage[], isSearch?: boolean) => {
packages = isSearch ? pkgs : pkgs.sort((a, b) => { packages = isSearch
if (sortBy === 'popularity') { ? pkgs
const aPop = +a.dl_count + a.installs; : pkgs.sort((a, b) => {
const bPop = +b.dl_count + b.installs; if (sortBy === 'popularity') {
return sortDirection === 'asc' ? aPop - bPop : bPop - aPop; const aPop = +a.dl_count + a.installs;
} else { const bPop = +b.dl_count + b.installs;
// most recent return sortDirection === 'asc' ? aPop - bPop : bPop - aPop;
const aDate = new Date(a.last_modified); } else {
const bDate = new Date(b.last_modified); // most recent
return sortDirection === 'asc' ? +aDate - +bDate : +bDate - +aDate; const aDate = new Date(a.last_modified);
} const bDate = new Date(b.last_modified);
}); return sortDirection === 'asc' ? +aDate - +bDate : +bDate - +aDate;
}
});
}; };
packagesStore.subscribe((v) => { packagesStore.subscribe((v) => {