Bug 1639166: Avoid updating if no changes. r=rcaliman

Differential Revision: https://phabricator.services.mozilla.com/D76655
This commit is contained in:
Daisuke Akatsuka 2020-05-26 01:43:42 +00:00
parent fe1f281e9e
commit 2244e12045

View File

@ -100,9 +100,13 @@ class CompatibilityView {
_onChangeAdded({ selector }) {
if (!this._isAvailable()) {
// In order to update this panel if a change is added while hiding this panel.
this._isChangeAddedWhileHidden = true;
return;
}
this._isChangeAddedWhileHidden = false;
// We need to debounce updating nodes since "add-change" event on changes actor is
// fired for every typed character until fixing bug 1503036.
if (this._previousChangedSelector === selector) {
@ -119,8 +123,28 @@ class CompatibilityView {
}
_onPanelSelected() {
this._onSelectedNodeChanged();
this._onTopLevelTargetChanged();
const {
selectedNode,
topLevelTarget,
} = this.inspector.store.getState().compatibility;
// Update if the selected node is changed or new change is added while the panel was hidden.
if (
this.inspector.selection.nodeFront !== selectedNode ||
this._isChangeAddedWhileHidden
) {
this._onSelectedNodeChanged();
}
// Update if the top target has changed or new change is added while the panel was hidden.
if (
this.inspector.toolbox.target !== topLevelTarget ||
this._isChangeAddedWhileHidden
) {
this._onTopLevelTargetChanged();
}
this._isChangeAddedWhileHidden = false;
}
_onSelectedNodeChanged() {