diff --git a/webadmin/src/js/appstore.js b/webadmin/src/js/appstore.js index 4928e3df1..dad8bcc19 100644 --- a/webadmin/src/js/appstore.js +++ b/webadmin/src/js/appstore.js @@ -79,6 +79,19 @@ angular.module('Application').service('AppStore', ['$http', '$base64', 'Client', }); }; + AppStore.prototype.getAppById = function (appId, callback) { + if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm')); + + // do not check cache, always get the latest + + $http.get(Client.getConfig().apiServerOrigin + '/api/v1/apps/' + appId).success(function (data, status) { + if (status !== 200) return callback(new AppStoreError(status, data)); + return callback(null, data); + }).error(function (data, status) { + return callback(new AppStoreError(status, data)); + }); + }; + AppStore.prototype.getManifest = function (appId, callback) { if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm')); diff --git a/webadmin/src/views/appstore.js b/webadmin/src/views/appstore.js index 3d0d10770..3180d4353 100644 --- a/webadmin/src/views/appstore.js +++ b/webadmin/src/views/appstore.js @@ -458,15 +458,15 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca $scope.appInstall.show(result); }); } else { - var found = $scope.apps.filter(function (app) { - return (app.id === appId) && (version ? version === app.manifest.version : true); - }); + AppStore.getAppById(appId, function (error, result) { + if (error) { + $scope.showAppNotFound(appId, null); + console.error(error); + return; + } - if (found.length) { - $scope.appInstall.show(found[0]); - } else { - $scope.showAppNotFound(appId, null); - } + $scope.appInstall.show(result); + }); } } else { $scope.appInstall.reset();