Don't fail if we can't find an application

Instead of logging and passing null through, explicitly skip
apps we don't know about.  It's valid to have say uninstalled
an app.
This commit is contained in:
Colin Walters 2009-07-08 11:54:15 -04:00
parent 0971ba54b8
commit 3b603ef7e0

View File

@ -673,12 +673,16 @@ AppWell.prototype = {
this._redisplay(); this._redisplay();
}, },
_lookupApp: function(id) { _lookupApps: function(appIds) {
let app = this._appSystem.lookup_app(id); let result = [];
if (!app) { for (let i = 0; i < appIds.length; i++) {
log("failed to look up app " + id); let id = appIds[i];
}; let app = this._appSystem.lookup_app(id);
return app; if (!app)
continue;
result.push(app);
}
return result;
}, },
_redisplay: function() { _redisplay: function() {
@ -693,8 +697,8 @@ AppWell.prototype = {
let runningIds = this._appMonitor.get_running_app_ids().filter(function (e) { let runningIds = this._appMonitor.get_running_app_ids().filter(function (e) {
return !(e in favoriteIdsObject); return !(e in favoriteIdsObject);
}); });
let favorites = favoriteIds.map(Lang.bind(this, this._lookupApp)); let favorites = this._lookupApps(favoriteIds);
let running = runningIds.map(Lang.bind(this, this._lookupApp)); let running = this._lookupApps(runningIds);
this._favoritesArea.redisplay(favorites); this._favoritesArea.redisplay(favorites);
this._runningArea.redisplay(running); this._runningArea.redisplay(running);
// If it's empty, we hide it so the top border doesn't show up // If it's empty, we hide it so the top border doesn't show up