diff --git a/src/views/appstore.html b/src/views/appstore.html
index 80c7b872f..aeb032226 100644
--- a/src/views/appstore.html
+++ b/src/views/appstore.html
@@ -267,6 +267,7 @@
Popular
+ New Apps
Recently Updated
All
diff --git a/src/views/appstore.js b/src/views/appstore.js
index 49fa9a838..798b71102 100644
--- a/src/views/appstore.js
+++ b/src/views/appstore.js
@@ -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 {