Fix display of app install dialog when no version is provided

This commit is contained in:
Girish Ramakrishnan
2018-01-05 11:58:53 -08:00
parent ff4d3de1b1
commit 28c1a70ae1
2 changed files with 21 additions and 8 deletions

View File

@@ -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'));

View File

@@ -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();