Skip to content

Commit 4371858

Browse files
Add a few events to make integrations easier
1 parent 2823d7e commit 4371858

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Map.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class Map extends Component {
1717
constructor(props) {
1818
super(props);
1919
window.addEventListener("message", ({ data, source }) => {
20-
this.updateSelected.bind(this)(data.selectedNodes, false);
20+
if ('selectedNodes' in data) {
21+
this.updateSelected.bind(this)(data.selectedNodes, false);
22+
}
2123
});
2224
}
2325

@@ -29,7 +31,7 @@ class Map extends Component {
2931
}
3032
if (triggerEvent) {
3133
console.log(`[map] Posting update: ${selectedNodes}`);
32-
window.parent.postMessage({selectedNodes: selectedNodes}, MESHDB_URL);
34+
window.parent.postMessage({selectedNodes: selectedNodes}, "*");
3335
}
3436
}
3537

src/actions/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export function fetchNodes(dispatch) {
55
.then(res => res.json())
66
.then(json => {
77
console.log("Fetched Nodes");
8+
window.parent.postMessage({type: "FETCH_NODES_SUCCESS"}, "*");
89
dispatch({ type: "FETCH_NODES_SUCCESS", nodes: json });
910
})
1011
.catch(err => console.log(err));
@@ -15,6 +16,7 @@ export function fetchLinks(dispatch) {
1516
.then(res => res.json())
1617
.then(json => {
1718
dispatch({ type: "FETCH_LINKS_SUCCESS", links: json });
19+
window.parent.postMessage({type: "FETCH_LINKS_SUCCESS"}, "*");
1820
})
1921
.catch(err => console.log(err));
2022
}
@@ -24,6 +26,7 @@ export function fetchSectors(dispatch) {
2426
.then(res => res.json())
2527
.then(json => {
2628
dispatch({ type: "FETCH_SECTORS_SUCCESS", sectors: json });
29+
window.parent.postMessage({type: "FETCH_SECTORS_SUCCESS"}, "*");
2730
})
2831
.catch(err => console.log(err));
2932
}
@@ -33,6 +36,7 @@ export function fetchKiosks(dispatch) {
3336
.then(res => res.json())
3437
.then(json => {
3538
dispatch({ type: "FETCH_KIOSKS_SUCCESS", kiosks: json });
39+
window.parent.postMessage({type: "FETCH_KIOSKS_SUCCESS"}, "*");
3640
})
3741
.catch(err => console.log(err));
3842
}

0 commit comments

Comments
 (0)