diff --git a/src/views/appstore.html b/src/views/appstore.html
index 226e18683..9a5f87afc 100644
--- a/src/views/appstore.html
+++ b/src/views/appstore.html
@@ -267,6 +267,7 @@
Popular
+ Recently Updated
All
Analytics
diff --git a/src/views/appstore.js b/src/views/appstore.js
index 6e9707260..9b617d0e1 100644
--- a/src/views/appstore.js
+++ b/src/views/appstore.js
@@ -3,6 +3,7 @@
/* global angular:false */
/* global $:false */
/* global ERROR */
+/* global moment */
angular.module('Application').controller('AppStoreController', ['$scope', '$location', '$timeout', '$routeParams', 'Client', function ($scope, $location, $timeout, $routeParams, Client) {
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
@@ -389,6 +390,19 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
});
};
+ function filterForRecentlyUpdatedApps(apps) {
+ var minApps = apps.length < 5 ? apps.length : 5; // prevent endless loop
+ var tmp = [];
+ var i = 0;
+
+ do {
+ var offset = moment().subtract(i++, 'days');
+ tmp = apps.filter(function (app) { return moment(app.creationDate).isAfter(offset); });
+ } while(tmp.length < minApps);
+
+ return tmp;
+ }
+
$scope.showCategory = function (event, category) {
if (!event) $scope.category = category;
else $scope.category = event.target.getAttribute('category');
@@ -402,6 +416,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 === 'recent') {
+ $scope.apps = filterForRecentlyUpdatedApps(apps);
} else {
$scope.apps = apps.filter(function (app) {
return app.manifest.tags.some(function (tag) { return $scope.category === tag; });