appstore: fix broken popularity sorting on chromium

This commit is contained in:
Alexandre Aubin 2023-09-25 14:40:49 +02:00
parent 07e5ba7edf
commit edfa399c45
2 changed files with 6 additions and 10 deletions

View File

@ -234,17 +234,17 @@
toSort = Array.prototype.slice.call(toSort, 0); toSort = Array.prototype.slice.call(toSort, 0);
if (sortBy === "newest") { if (sortBy === "newest") {
toSort.sort(function(a, b) { toSort.sort(function(a, b) {
return a.dataset.addedincatalog - b.dataset.addedincatalog; return a.dataset.addedincatalog - b.dataset.addedincatalog ? 1 : -1;
}); });
} }
else if (sortBy === "popularity") { else if (sortBy === "popularity") {
toSort.sort(function(a, b) { toSort.sort(function(a, b) {
return a.dataset.stars < b.dataset.stars; return a.dataset.stars < b.dataset.stars ? 1 : -1;
}); });
} }
else if (sortBy === "") { else if (sortBy === "") {
toSort.sort(function(a, b) { toSort.sort(function(a, b) {
return a.dataset.appid > b.dataset.appid; return a.dataset.appid > b.dataset.appid ? 1 : -1;
}); });
} }
var parent = document.getElementById(container_to_sort); var parent = document.getElementById(container_to_sort);

View File

@ -204,20 +204,19 @@
let sortBy = selectSort.value.trim(); let sortBy = selectSort.value.trim();
var toSort = document.getElementById(container_to_sort).children; var toSort = document.getElementById(container_to_sort).children;
toSort = Array.prototype.slice.call(toSort, 0); toSort = Array.prototype.slice.call(toSort, 0);
console.log(sortBy);
if (sortBy === "newest") { if (sortBy === "newest") {
toSort.sort(function(a, b) { toSort.sort(function(a, b) {
return a.dataset.addedincatalog - b.dataset.addedincatalog; return a.dataset.addedincatalog - b.dataset.addedincatalog ? 1 : -1;
}); });
} }
else if (sortBy === "popularity") { else if (sortBy === "popularity") {
toSort.sort(function(a, b) { toSort.sort(function(a, b) {
return a.dataset.stars < b.dataset.stars; return a.dataset.stars < b.dataset.stars ? 1 : -1;
}); });
} }
else if (sortBy === "") { else if (sortBy === "") {
toSort.sort(function(a, b) { toSort.sort(function(a, b) {
return a.dataset.appid > b.dataset.appid; return a.dataset.appid > b.dataset.appid ? 1 : -1;
}); });
} }
var parent = document.getElementById(container_to_sort); var parent = document.getElementById(container_to_sort);
@ -226,7 +225,6 @@
for(var i = 0, l = toSort.length; i < l; i++) { for(var i = 0, l = toSort.length; i < l; i++) {
parent.appendChild(toSort[i]); parent.appendChild(toSort[i]);
} }
console.log("gni?")
updateQueryArgsInURL() updateQueryArgsInURL()
} }
@ -243,8 +241,6 @@
if (sortBy) { queryArgs.set("sort", sortBy) } else { queryArgs.delete("sort"); }; if (sortBy) { queryArgs.set("sort", sortBy) } else { queryArgs.delete("sort"); };
if (starsOnly) { queryArgs.set("starsonly", true) } else { queryArgs.delete("starsonly"); }; if (starsOnly) { queryArgs.set("starsonly", true) } else { queryArgs.delete("starsonly"); };
console.log(queryArgs.toString());
let newUrl; let newUrl;
if (queryArgs.toString()) if (queryArgs.toString())
{ {