Use task api to get app progress
This commit is contained in:
@@ -1407,19 +1407,6 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
Client.prototype._appPostProcess = function (app) { // calculate the icon paths
|
||||
app.iconUrl = app.iconUrl ? (this.apiOrigin + app.iconUrl + '?access_token=' + token + '&' + String(Math.random()).slice(2)) : null;
|
||||
|
||||
// FIXME have a real message structure, not some string to randomly parse
|
||||
// extract progress percentage
|
||||
var installationProgress = app.installationProgress || '';
|
||||
var progress = parseInt(installationProgress.split(',')[0], 10);
|
||||
// Unfortunately some errors are not actual progress messages, but still have a number in fron like a http status code
|
||||
if (isNaN(progress) || progress > 100) {
|
||||
app.progress = 0;
|
||||
app.message = installationProgress;
|
||||
} else {
|
||||
app.progress = progress;
|
||||
app.message = installationProgress.replace(/.*, /,'');
|
||||
}
|
||||
|
||||
// amend the post install confirm state
|
||||
app.pendingPostInstallConfirmation = !!localStorage['confirmPostInstall_' + app.id];
|
||||
|
||||
@@ -1488,9 +1475,20 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
this.getApp(id, function (error, app) {
|
||||
if (error) return callback(error);
|
||||
|
||||
that._updateAppCache(app);
|
||||
var getTaskFunc = app.taskId ? that.getTask.bind(null, app.taskId) : function (next) { return next(); };
|
||||
|
||||
callback(null, app);
|
||||
getTaskFunc(function (error, task) {
|
||||
if (error) return callback(error);
|
||||
|
||||
if (task) {
|
||||
app.progress = task.percent;
|
||||
app.message = task.message;
|
||||
}
|
||||
|
||||
that._updateAppCache(app);
|
||||
|
||||
callback(null, app);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1510,7 +1508,9 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
return iteratorCallback();
|
||||
}
|
||||
|
||||
if (that._installedAppsById[app.id] && that._installedAppsById[app.id].ts === app.ts) return iteratorCallback(); // app has not changed
|
||||
if (that._installedAppsById[app.id] && that._installedAppsById[app.id].ts === app.ts) {
|
||||
if (!app.taskId) return iteratorCallback(); // app has not changed and no task to check progress
|
||||
}
|
||||
|
||||
that.refreshAppCache(app.id, iteratorCallback);
|
||||
}, function iteratorDone(error) {
|
||||
|
||||
Reference in New Issue
Block a user