Use local cache when looking up apps

This commit is contained in:
Johannes Zellner
2016-01-25 16:25:25 +01:00
parent 61c2ce0f47
commit c384ac6080

View File

@@ -66,6 +66,11 @@ angular.module('Application').service('AppStore', ['$http', 'Client', function (
AppStore.prototype.getAppByIdAndVersion = function (appId, version, callback) {
if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm'));
// check cache
for (var app in this._appsCache) {
if (this._appsCache[app].id === appId && this._appsCache[app].manifest.version === version) return callback(null, this._appsCache[app]);
}
$http.get(Client.getConfig().apiServerOrigin + '/api/v1/apps/' + appId + '/versions/' + version).success(function (data, status) {
if (status !== 200) return callback(new AppStoreError(status, data));
return callback(null, data);