Add new apps category in appstore view

This commit is contained in:
Johannes Zellner
2019-11-18 22:43:33 +01:00
parent bcb055ed05
commit c7a5d295ec
2 changed files with 16 additions and 0 deletions

View File

@@ -390,6 +390,19 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
});
};
function filterForNewApps(apps) {
var minApps = apps.length < 3 ? apps.length : 3; // prevent endless loop
var tmp = [];
var i = 0;
do {
var offset = moment().subtract(i++, 'days');
tmp = apps.filter(function (app) { return moment(app.ts).isAfter(offset); });
} while(tmp.length < minApps);
return tmp;
}
function filterForRecentlyUpdatedApps(apps) {
var minApps = apps.length < 5 ? apps.length : 5; // prevent endless loop
var tmp = [];
@@ -416,6 +429,8 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
$scope.apps = apps;
} else if ($scope.category === 'featured') {
$scope.apps = apps.filter(function (app) { return app.featured; });
} else if ($scope.category === 'new') {
$scope.apps = filterForNewApps(apps);
} else if ($scope.category === 'recent') {
$scope.apps = filterForRecentlyUpdatedApps(apps);
} else {