зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1124425 - Clean up listTabs promises. r=ochameau
This commit is contained in:
Родитель
5b39b1ea41
Коммит
8b313a4ba1
|
@ -677,7 +677,7 @@ let UI = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore unselection of project on runtime disconnection
|
// Ignore unselection of project on runtime disconnection
|
||||||
if (AppManager.connection.status != Connection.Status.CONNECTED) {
|
if (!AppManager.connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ let UI = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// For other project types, we need to be connected to the runtime
|
// For other project types, we need to be connected to the runtime
|
||||||
if (AppManager.connection.status != Connection.Status.CONNECTED) {
|
if (!AppManager.connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,7 +821,7 @@ let UI = {
|
||||||
let debugCmd = document.querySelector("#cmd_toggleToolbox");
|
let debugCmd = document.querySelector("#cmd_toggleToolbox");
|
||||||
let playButton = document.querySelector('#action-button-play');
|
let playButton = document.querySelector('#action-button-play');
|
||||||
|
|
||||||
if (!AppManager.selectedProject || AppManager.connection.status != Connection.Status.CONNECTED) {
|
if (!AppManager.selectedProject || !AppManager.connected) {
|
||||||
playCmd.setAttribute("disabled", "true");
|
playCmd.setAttribute("disabled", "true");
|
||||||
stopCmd.setAttribute("disabled", "true");
|
stopCmd.setAttribute("disabled", "true");
|
||||||
debugCmd.setAttribute("disabled", "true");
|
debugCmd.setAttribute("disabled", "true");
|
||||||
|
@ -874,7 +874,7 @@ let UI = {
|
||||||
let box = document.querySelector("#runtime-actions");
|
let box = document.querySelector("#runtime-actions");
|
||||||
|
|
||||||
let runtimePanelButton = document.querySelector("#runtime-panel-button");
|
let runtimePanelButton = document.querySelector("#runtime-panel-button");
|
||||||
if (AppManager.connection.status == Connection.Status.CONNECTED) {
|
if (AppManager.connected) {
|
||||||
if (AppManager.deviceFront) {
|
if (AppManager.deviceFront) {
|
||||||
detailsCmd.removeAttribute("disabled");
|
detailsCmd.removeAttribute("disabled");
|
||||||
permissionsCmd.removeAttribute("disabled");
|
permissionsCmd.removeAttribute("disabled");
|
||||||
|
@ -1103,8 +1103,7 @@ let Cmds = {
|
||||||
return a.manifest.name > b.manifest.name;
|
return a.manifest.name > b.manifest.name;
|
||||||
});
|
});
|
||||||
let mainProcess = AppManager.isMainProcessDebuggable();
|
let mainProcess = AppManager.isMainProcessDebuggable();
|
||||||
if (AppManager.connection.status == Connection.Status.CONNECTED &&
|
if (AppManager.connected && (sortedApps.length > 0 || mainProcess)) {
|
||||||
(sortedApps.length > 0 || mainProcess)) {
|
|
||||||
runtimeappsHeaderNode.removeAttribute("hidden");
|
runtimeappsHeaderNode.removeAttribute("hidden");
|
||||||
} else {
|
} else {
|
||||||
runtimeappsHeaderNode.setAttribute("hidden", "true");
|
runtimeappsHeaderNode.setAttribute("hidden", "true");
|
||||||
|
@ -1154,9 +1153,11 @@ let Cmds = {
|
||||||
|
|
||||||
// But re-list them and rebuild, in case any tabs navigated since the last
|
// But re-list them and rebuild, in case any tabs navigated since the last
|
||||||
// time they were listed.
|
// time they were listed.
|
||||||
AppManager.listTabs().then(() => {
|
if (AppManager.connected) {
|
||||||
this._buildProjectPanelTabs();
|
AppManager.listTabs().then(() => {
|
||||||
});
|
this._buildProjectPanelTabs();
|
||||||
|
}).catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
|
@ -1164,8 +1165,7 @@ let Cmds = {
|
||||||
_buildProjectPanelTabs: function() {
|
_buildProjectPanelTabs: function() {
|
||||||
let tabs = AppManager.tabStore.tabs;
|
let tabs = AppManager.tabStore.tabs;
|
||||||
let tabsHeaderNode = document.querySelector("#panel-header-tabs");
|
let tabsHeaderNode = document.querySelector("#panel-header-tabs");
|
||||||
if (AppManager.connection.status == Connection.Status.CONNECTED &&
|
if (AppManager.connected && tabs.length > 0) {
|
||||||
tabs.length > 0) {
|
|
||||||
tabsHeaderNode.removeAttribute("hidden");
|
tabsHeaderNode.removeAttribute("hidden");
|
||||||
} else {
|
} else {
|
||||||
tabsHeaderNode.setAttribute("hidden", "true");
|
tabsHeaderNode.setAttribute("hidden", "true");
|
||||||
|
|
|
@ -99,7 +99,7 @@ let AppManager = exports.AppManager = {
|
||||||
this.selectedRuntime = null;
|
this.selectedRuntime = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.connection.status != Connection.Status.CONNECTED) {
|
if (!this.connected) {
|
||||||
if (this._appsFront) {
|
if (this._appsFront) {
|
||||||
this._appsFront.off("install-progress", this.onInstallProgress);
|
this._appsFront.off("install-progress", this.onInstallProgress);
|
||||||
this._appsFront.unwatchApps();
|
this._appsFront.unwatchApps();
|
||||||
|
@ -136,6 +136,10 @@ let AppManager = exports.AppManager = {
|
||||||
this.update("connection");
|
this.update("connection");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get connected() {
|
||||||
|
return this.connection.status == Connection.Status.CONNECTED;
|
||||||
|
},
|
||||||
|
|
||||||
get apps() {
|
get apps() {
|
||||||
if (this._appsFront) {
|
if (this._appsFront) {
|
||||||
return this._appsFront.apps;
|
return this._appsFront.apps;
|
||||||
|
@ -336,8 +340,7 @@ let AppManager = exports.AppManager = {
|
||||||
|
|
||||||
connectToRuntime: function(runtime) {
|
connectToRuntime: function(runtime) {
|
||||||
|
|
||||||
if (this.connection.status == Connection.Status.CONNECTED &&
|
if (this.connected && this.selectedRuntime === runtime) {
|
||||||
this.selectedRuntime === runtime) {
|
|
||||||
// Already connected
|
// Already connected
|
||||||
return promise.resolve();
|
return promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -350,7 +353,7 @@ let AppManager = exports.AppManager = {
|
||||||
let onConnectedOrDisconnected = () => {
|
let onConnectedOrDisconnected = () => {
|
||||||
this.connection.off(Connection.Events.CONNECTED, onConnectedOrDisconnected);
|
this.connection.off(Connection.Events.CONNECTED, onConnectedOrDisconnected);
|
||||||
this.connection.off(Connection.Events.DISCONNECTED, onConnectedOrDisconnected);
|
this.connection.off(Connection.Events.DISCONNECTED, onConnectedOrDisconnected);
|
||||||
if (this.connection.status == Connection.Status.CONNECTED) {
|
if (this.connected) {
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
} else {
|
} else {
|
||||||
deferred.reject();
|
deferred.reject();
|
||||||
|
@ -413,7 +416,7 @@ let AppManager = exports.AppManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
disconnectRuntime: function() {
|
disconnectRuntime: function() {
|
||||||
if (this.connection.status != Connection.Status.CONNECTED) {
|
if (!this.connected) {
|
||||||
return promise.resolve();
|
return promise.resolve();
|
||||||
}
|
}
|
||||||
let deferred = promise.defer();
|
let deferred = promise.defer();
|
||||||
|
|
|
@ -96,7 +96,7 @@ TabStore.prototype = {
|
||||||
|
|
||||||
listTabs: function() {
|
listTabs: function() {
|
||||||
if (!this._connection || !this._connection.client) {
|
if (!this._connection || !this._connection.client) {
|
||||||
return promise.reject();
|
return promise.reject(new Error("Can't listTabs, not connected."));
|
||||||
}
|
}
|
||||||
let deferred = promise.defer();
|
let deferred = promise.defer();
|
||||||
this._connection.client.listTabs(response => {
|
this._connection.client.listTabs(response => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче