Fix bug where location change makes the app temporarily disappear
This commit is contained in:
@@ -1768,30 +1768,20 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
}
|
||||
|
||||
Client.prototype._updateAppCache = function (app) {
|
||||
var found = -1;
|
||||
|
||||
// find by id and not by loc because the app's fqdn might have changed between invokations
|
||||
for (var i = 0; i < this._installedApps.length; ++i) {
|
||||
if (this._installedApps[i].id === app.id) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var tmp = {};
|
||||
angular.copy(app, tmp);
|
||||
|
||||
// only replace if the app is already known
|
||||
if (found !== -1 && this._installedApps[found].fqdn === tmp.fqdn) { // app location has not changed
|
||||
angular.copy(tmp, this._installedApps[found]);
|
||||
} else if (found !== -1) {
|
||||
this._installedApps.splice(found, 1); // remove it
|
||||
var foundIndex = this._installedApps.findIndex(function (a) { return a.id === app.id; });
|
||||
|
||||
// we replace new data into the existing reference to keep angular bindings
|
||||
if (foundIndex !== -1) {
|
||||
angular.copy(tmp, this._installedApps[foundIndex]);
|
||||
} else {
|
||||
var loc = binarySearch(this._installedApps, function (item) { return item.fqdn.localeCompare(app.fqdn) <= 0; });
|
||||
this._installedApps.splice(loc, 0, tmp); // insert into sorted fqdn array
|
||||
this._installedApps.push(tmp);
|
||||
}
|
||||
|
||||
this._installedAppsById[app.id] = this._installedApps[found];
|
||||
// add reference to object map with appId keys
|
||||
this._installedAppsById[app.id] = this._installedApps[foundIndex];
|
||||
|
||||
// TODO this not very elegant
|
||||
// update app tags
|
||||
|
||||
Reference in New Issue
Block a user