Show popular apps first when no category is selected

This commit is contained in:
Johannes Zellner
2021-03-18 14:14:22 +01:00
parent 09e07868bb
commit 050ea48e3e
2 changed files with 32 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran
$scope.ready = false;
$scope.apps = [];
$scope.popularApps = [];
$scope.config = Client.getConfig();
$scope.user = Client.getUserInfo();
$scope.users = [];
@@ -425,6 +426,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran
var token = $scope.searchString.toUpperCase();
$scope.popularApps = [];
$scope.apps = apps.filter(function (app) {
if (app.manifest.id.toUpperCase().indexOf(token) !== -1) return true;
if (app.manifest.title.toUpperCase().indexOf(token) !== -1) return true;
@@ -432,7 +434,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran
if (app.manifest.tags.join().toUpperCase().indexOf(token) !== -1) return true;
if (app.manifest.description.toUpperCase().indexOf(token) !== -1) return true;
return false;
});
});
});
};
@@ -471,7 +473,9 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran
if (error) return $timeout($scope.showCategory.bind(null, category), 1000);
if (!$scope.category) {
$scope.apps = apps.slice(0).sort(function (a1, a2) { return a1.manifest.title.localeCompare(a2.manifest.title); });
$scope.apps = apps.slice(0).filter(function (app) { return !app.featured; }).sort(function (a1, a2) { return a1.manifest.title.localeCompare(a2.manifest.title); });
$scope.popularApps = apps.slice(0).filter(function (app) { return app.featured; }).sort(function (a1, a2) { return a2.ranking - a1.ranking; });
// $scope.apps = apps.slice(0).sort(function (a1, a2) { return a1.manifest.title.localeCompare(a2.manifest.title); });
} else if ($scope.category === 'featured') {
$scope.apps = apps.filter(function (app) { return app.featured; }).sort(function (a1, a2) { return a2.ranking - a1.ranking; }); // reverse sort
} else if ($scope.category === 'new') {