Skip to content

Commit

Permalink
WEB-2: Dep-tree viewer gets updated only when root changes
Browse files Browse the repository at this point in the history
  • Loading branch information
edwingamboa committed Dec 22, 2017
1 parent 9e5d8dd commit 7b65252
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/devtools.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* globals chrome */
(function () {
var CONNECTION_VWR_TAB_ID = 'componentViewerT';
var DEP_TREE_VWR_TAB_ID = 'depsTreeViewerT';
var cubblesPanelWindow;
var cubblesSidepanelWindow;
var componentVwr;
Expand Down Expand Up @@ -30,13 +31,13 @@
* the information
*/
function requestInformation (force) {
if (cifIsReadyInCubblesPanel() && !componentVwrIsWorking()) {
if (cifIsReadyInCubblesPanel()) {
var activeTab = cubblesPanelWindow.document.querySelector('ul.nav-tabs li.active a');
if (activeTab.id === CONNECTION_VWR_TAB_ID) {
if (activeTab.id === CONNECTION_VWR_TAB_ID && !componentVwrIsWorking()) {
adjustDataflowHeight();
var currentDefs = componentVwr.getDefinitions();
postMessage('get-definitions', force || false);
} else if (shouldRequestDepTree) {
} else if (activeTab.id === DEP_TREE_VWR_TAB_ID && shouldRequestDepTree) {
postMessage('get-dep-tree', force);
adjustDepTreeView();
shouldRequestDepTree = false;
Expand Down
8 changes: 7 additions & 1 deletion lib/injected_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var connectionIds = [];
var dependencyTree;
var lastSentDefs;
var rootCrcId = '';

document.addEventListener('getInfo', function (e) {
if (cifIsReady()) {
Expand Down Expand Up @@ -139,7 +140,8 @@
// Finally build rawDependency tree providing DepReference list and baseUrl
depMgr._buildRawDependencyTree(deps, window.cubx.CRC._baseUrl)
.then(function (depTree) {
if (force || depTree !== dependencyTree) {
if (force || _isNewRoot(window.cubx.CRC._crcElId)) {
rootCrcId = window.cubx.CRC._crcElId;
postMessage('set-dep-tree', depTreeToJSON(depTree));
dependencyTree = depTree;
}
Expand Down Expand Up @@ -190,6 +192,10 @@
return jsonObject;
}

function _isNewRoot (newRootCrcId) {
return newRootCrcId !== rootCrcId;
}

function _sameConnectionsIds (currentDefs, newDefs) {
var currentConnectionIds = _extractConnectionIds(currentDefs) || [];
var newConnectionIds = _extractConnectionIds(newDefs) || [];
Expand Down

0 comments on commit 7b65252

Please sign in to comment.