Skip to content

Commit b42eea5

Browse files
davidchai717nusanam
andcommitted
Fixes and further debugging
Co-authored-by: Ruth Anam <[email protected]> Co-authored-by: David Chai <[email protected]>
2 parents f8037a9 + 40079aa commit b42eea5

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"Bryan Lee",
2626
"David Chai",
2727
"Josh Kim",
28-
"Ruthba Anam",
28+
"Ruth Anam",
2929
"Ryan Dang",
3030
"Sierra Swaby",
3131
"Yujin Kang"

src/app/components/Chart.jsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ class Chart extends Component {
1515
this.maked3Tree = this.maked3Tree.bind(this);
1616
}
1717
componentDidMount() {
18-
const { hierarchy } = this.props;
19-
root = JSON.parse(JSON.stringify(hierarchy));
20-
console.log('props', this.props)
18+
const { snapshot, hierarchy } = this.props;
19+
console.log('initial props', this.props)
20+
root = JSON.parse(JSON.stringify(snapshot));
2121
this.maked3Tree();
2222
}
2323

2424
componentDidUpdate() {
25-
const { hierarchy } = this.props;
26-
root = JSON.parse(JSON.stringify(hierarchy));
25+
const { snapshot, hierarchy } = this.props;
26+
console.log('updated props', this.props)
27+
root = JSON.parse(JSON.stringify(snapshot));
2728
this.maked3Tree();
2829
}
2930

@@ -60,8 +61,6 @@ class Chart extends Component {
6061

6162
let d3root = tree(hierarchy);
6263

63-
console.log('children', d3root.descendants());
64-
6564
g.selectAll('.link')
6665
// root.links() gets an array of all the links, where each element is an object containing a source property, which represents the link's source node, and a target property, which represents the link's target node.
6766
.data(d3root.links())

src/app/containers/MainContainer.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ function MainContainer() {
2424
// listen for a message containing snapshots from the background script
2525
port.onMessage.addListener(message => {
2626
const { action, payload, sourceTab } = message;
27+
console.log('action message', action);
28+
console.log('payload message', message)
2729
switch (action) {
2830
case 'deleteTab': {
2931
dispatch(deleteTab(payload));
@@ -65,7 +67,8 @@ function MainContainer() {
6567
</div>
6668
);
6769
}
68-
const { viewIndex, sliderIndex, snapshots } = tabs[currentTab];
70+
const { viewIndex, sliderIndex, snapshots, hierarchy } = tabs[currentTab];
71+
console.log('main container', tabs[currentTab]);
6972

7073
// if viewIndex is -1, then use the sliderIndex instead
7174
const snapshotView = viewIndex === -1 ? snapshots[sliderIndex] : snapshots[viewIndex];

src/app/containers/StateContainer.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {
66
import StateRoute from '../components/StateRoute';
77
import DiffRoute from '../components/DiffRoute';
88

9+
910
const StateContainer = ({ snapshot, hierarchy }) => {
11+
console.log('passing?', hierarchy);
1012
const [Text, setText] = useState('State');
1113
return (
1214
<Router>

src/extension/background.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ const makeNewNode = () => {
3333
this.children = [];
3434
}
3535
};
36-
}
36+
};
37+
3738
const Node = makeNewNode();
3839

39-
function buildHierachy(tabObj, newNode) {
40+
function sendToHierarchy (tabObj, newNode) {
4041
if (!tabObj.currLocation) {
4142
tabObj.currLocation = newNode;
42-
tabObj.hierachy = newNode;
43+
tabObj.hierarchy = newNode;
4344
} else {
4445
tabObj.currLocation.children.push(newNode);
4546
tabObj.currLocation = newNode;
4647
}
4748
}
48-
49-
function changeCurrLocation(tabObj, currNode, index) {
49+
function changeCurrLocation (tabObj, rootNode, index) {
5050
// check if current node has the index wanted
51-
if (currNode.index === index) {
52-
tabObj.currLocation = currNode;
51+
if (rootNode.index === index) {
52+
tabObj.currLocation = rootNode;
5353
return;
5454
}
5555
// base case if no children
56-
if (!currNode.children.length) {
56+
if (!rootNode.children.length) {
5757
return;
5858
} else {
5959
// if not, recurse on each one of the children
60-
currNode.children.forEach(child => {
60+
rootNode.children.forEach(child => {
6161
changeCurrLocation(tabObj, child, index);
6262
});
6363
}
@@ -72,7 +72,7 @@ chrome.runtime.onConnect.addListener(port => {
7272
if (Object.keys(tabsObj).length > 0) {
7373
port.postMessage({
7474
action: 'initialConnectSnapshots',
75-
payload: tabsObj,
75+
payload: {...tabsObj, msg: 'connection to devgools made'},
7676
});
7777
}
7878

@@ -148,15 +148,16 @@ chrome.runtime.onMessage.addListener((request, sender) => {
148148
// dont remove snapshots if persisting
149149
if (!persist) {
150150
tabsObj[tabId].snapshots.splice(1);
151-
151+
152152
// send a message to devtools
153153
portsArr.forEach(bg => bg.postMessage({
154154
action: 'initialConnectSnapshots',
155-
payload: tabsObj,
155+
payload: { ...tabsObj, msg: 'reload' },
156156
}));
157157
}
158158

159159
reloaded[tabId] = true;
160+
160161

161162
break;
162163
}
@@ -169,15 +170,11 @@ chrome.runtime.onMessage.addListener((request, sender) => {
169170
reloaded[tabId] = false;
170171

171172
tabsObj[tabId].snapshots.push(request.payload);
172-
// invoking function to place a new d3 tree node in the right location
173-
const newNode = new Node(request.payload)
174-
buildHierarchy(tabsObj[tabId], newNode);
175-
176-
console.log(tabsObj[tabId].snapshots);
173+
sendToHierarchy(tabsObj[tabId], new Node(request.payload));
177174
if (portsArr.length > 0) {
178175
portsArr.forEach(bg => bg.postMessage({
179176
action: 'initialConnectSnapshots',
180-
payload: tabsObj,
177+
payload: {...tabsObj, msg: 'firstsnapshotreceived'},
181178
}));
182179
}
183180
break;
@@ -188,9 +185,8 @@ chrome.runtime.onMessage.addListener((request, sender) => {
188185
reloaded[tabId] = false;
189186
} else {
190187
tabsObj[tabId].snapshots.push(request.payload);
191-
// invoking function to place a new d3 tree node in the right location
192-
const newNode = new Node(request.payload)
193-
buildHierarchy(tabsObj[tabId], newNode);
188+
//! INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN!!!!
189+
sendToHierarchy(tabsObj[tabId], new Node(request.payload));
194190
}
195191
// send message to devtools
196192
if (portsArr.length > 0) {

src/extension/contentScript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ window.addEventListener('message', msg => {
1111
firstMessage = false;
1212
}
1313

14-
// post initial Message to npm package
14+
// post initial Message to background.js
1515
const { action } = msg.data;
1616
if (action === 'recordSnap') chrome.runtime.sendMessage(msg.data);
1717
});

0 commit comments

Comments
 (0)