Skip to content

Commit d47335d

Browse files
authored
Merge pull request #186 from open-source-labs/james/communicationsFix
communications bug fix
2 parents c4faff6 + 4482b53 commit d47335d

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

app/charts/RouteChart.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { CommsContext } from '../context/CommsContext';
1111

1212
const RouteChart = React.memo(() => {
1313
const communicationsData = useContext(CommsContext).commsData;
14+
15+
console.log('commdata before sort: ', communicationsData);
1416

1517
const resObj = {};
1618
const dataId = '_id';
@@ -21,12 +23,15 @@ const RouteChart = React.memo(() => {
2123
* The below sorts it back into ascending order.
2224
*/
2325

26+
2427
communicationsData.sort((a, b) => {
2528
if (new Date(a.time) > new Date(b.time)) return 1;
2629
if (new Date(a.time) < new Date(b.time)) return -1;
2730
return 0;
2831
});
2932

33+
console.log('commdata after sort: ', communicationsData[0], communicationsData[0].endpoint);
34+
3035
for (let i = 0; i < communicationsData.length; i += 1) {
3136
const element = communicationsData[i];
3237
if (!resObj[element.correlatingid]) resObj[element.correlatingid] = [];
@@ -57,6 +62,8 @@ const RouteChart = React.memo(() => {
5762

5863
const tracePoints = Object.values(resObj).filter(subArray => subArray.length > 1);
5964

65+
console.log('tracepoints: ', tracePoints);
66+
6067
const useStyles = makeStyles(theme => ({
6168
paper: {
6269
height: 300,

app/context/CommsContext.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,25 @@ const CommsContextProvider: React.SFC = React.memo(({ children }) => {
3333
}
3434

3535
const fetchCommsData = useCallback((app: string, live: boolean) => {
36-
if (app !== currentApp || live) {
36+
// console.log("CommsContext app is:", app);
37+
console.log("in the fetchCommsData");
38+
console.log("CommsContext live is: ", live);
39+
console.log("CommsContext current app is: ", currentApp);
40+
41+
// if (app !== currentApp || live) {
3742
ipcRenderer.removeAllListeners('commsResponse');
43+
console.log('current app in commscontext: ', app);
3844
setCurrentApp(app);
39-
ipcRenderer.send('commsRequest', app);
45+
//ipcRenderer.send('commsRequest', app);
46+
ipcRenderer.send('commsRequest');
4047
ipcRenderer.on('commsResponse', (event: Electron.Event, data: any) => {
4148
let result: any;
42-
49+
//
4350
if (tryParseJSON(data)) result = JSON.parse(data);
51+
console.log('result in commscontext fetch: ', result);
4452
setCommsData(result);
4553
});
46-
}
54+
// }
4755
}, []);
4856

4957
return (

app/modals/ServicesModal.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ const ServicesModal: React.FC<ServicesModalProps> = React.memo(({ i, app }) => {
5656
{service.microservice}
5757
</div>
5858
))}
59-
<div
60-
className={services.includes('communications') ? 'link selected' : 'link'}
61-
onClick={() => setServices(['communications'])}
62-
>
63-
communications
64-
</div>
6559
<Link id='selectLink'
6660
className="router link"
6761
to={services.length > 0 ? `/applications/${app}/${services.join(' ')}` : '#'}

electron/routes/data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ ipcMain.on('commsRequest', async (message: Electron.IpcMainEvent) => {
113113
result = await pool.query(getCommunications);
114114
result = result.rows;
115115
}
116-
116+
console.log('result from database query in data.ts: ', result)
117117
// Async event emitter - send response
118118
message.sender.send('commsResponse', JSON.stringify(result));
119119
} catch (error) {
120120
// Catch errors
121-
console.log('Error in "commeRequest" event', message);
122-
message.sender.send('commsResponse', {});
121+
console.log('Error in "commsRequest" event: ', error);
122+
// message.sender.send('commsResponse', {}); //comment back in later
123123
}
124124
});
125125

0 commit comments

Comments
 (0)