Skip to content

Commit f0ece06

Browse files
authored
Merge pull request #8 from xkiso/master
Fix latency issue with communications
2 parents 50f1307 + 2d082e5 commit f0ece06

File tree

7 files changed

+9
-19
lines changed

7 files changed

+9
-19
lines changed

app/components/Occupied.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const Occupied: React.FC = React.memo(function Occupied (props) {
6969
if (delRef.current[i] && !delRef.current[i].contains(event.target)) {
7070
setIndex(i);
7171
setApp(selectedApp);
72+
setServicesData([]);
7273
setOpen(true);
7374
}
7475
};

app/containers/GraphsContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface GraphsContainerProps {
3131
};
3232
}
3333

34-
const GraphsContainer: React.SFC<GraphsContainerProps> = () => {
34+
const GraphsContainer: React.FC<GraphsContainerProps> = React.memo(function GraphsContainer (props) {
3535
const { app, service } = useParams<any>();
3636
const [live, setLive] = useState<boolean>(false);
3737
const [intervalID, setIntervalID] = useState<NodeJS.Timeout | null>(null);
@@ -88,6 +88,6 @@ const GraphsContainer: React.SFC<GraphsContainerProps> = () => {
8888
</div>
8989
</>
9090
);
91-
};
91+
});
9292

9393
export default GraphsContainer;

app/context/CommsContext.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ const CommsContextProvider: React.FC = ({ children }) => {
1616
const [currentApp, setCurrentApp] = useState('');
1717

1818
// Fetches all data related to communication for a particular app
19-
const fetchCommsData = (app: string, live: boolean) => {
19+
const fetchCommsData = React.useCallback((app: string, live: boolean) => {
2020
/**
2121
* Caches results of requesting communication data for a specific app
2222
* Communication data will be the same across the microservices. Prevents
2323
* fetch requests that result in repeating data
2424
*/
2525
if (app !== currentApp || live) {
26+
ipcRenderer.removeAllListeners('commsResponse');
2627
setCurrentApp(app)
2728
ipcRenderer.send('commsRequest', app);
2829
ipcRenderer.on('commsResponse', (event: Electron.Event, data: any) => {
@@ -32,7 +33,7 @@ const CommsContextProvider: React.FC = ({ children }) => {
3233
setCommsData(result);
3334
});
3435
}
35-
};
36+
}, []);
3637

3738
return (
3839
<CommsContext.Provider value={{ commsData, setCommsData, fetchCommsData }}>

app/context/DockerContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const DockerContextProvider: React.FC = ({ children }) => {
1818

1919
// Fetches all data related to a particular app
2020
const fetchDockerData = (service: string) => {
21+
ipcRenderer.removeAllListeners('dockerResponse');
2122
ipcRenderer.send('dockerRequest', service);
2223

2324
ipcRenderer.on('dockerResponse', (event: Electron.Event, data: any) => {

app/context/HealthContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const HealthContextProvider: React.FC = ({ children }) => {
1515

1616
// Fetches all data related to a particular app
1717
const fetchHealthData = (service: string) => {
18+
ipcRenderer.removeAllListeners('healthResponse');
1819
ipcRenderer.send('healthRequest', service);
1920
ipcRenderer.on('healthResponse', (event: Electron.Event, data: any) => {
2021
let result: any;

electron/user/settings.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,12 @@
88
"Online bookstore with that keeps track of orders and customers",
99
"Jun 28, 2020 4:58 PM"
1010
],
11-
[
12-
"myMongo",
13-
"MongoDB",
14-
"mongodb+srv://chronos:[email protected]/chronos?retryWrites=true&w=majority",
15-
"E-commerce website for buying and selling clothes",
16-
"Jul 01, 2020 10:33 PM"
17-
],
1811
[
1912
"ToddDB",
2013
"MongoDB",
2114
"mongodb+srv://tdwolf6:[email protected]/Chronos?retryWrites=true&w=majority",
2215
"Web app deployed on AWS",
2316
"Jul 3, 2020 7:12AM"
24-
],
25-
[
26-
"pattyDB",
27-
"MongoDB",
28-
"mongodb+srv://chronos:[email protected]/chronos?retryWrites=true&w=majority",
29-
"dummy microservice: books/customer/orders/reverse-proxy",
30-
"Jul 3, 2020 11:12AM"
3117
]
3218
],
3319
"splash": true

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test:electron": "jest --detectOpenHandles ./__tests__/electron/*",
1414
"test:app": "jest ./__tests__/app/*",
1515
"both": "npm run start & sleep 5 && npm run electron",
16-
"both:tsc": "nodemon --watch ./app & npm run start & sleep 5 && npm run electron",
16+
"both:tsc": "nodemon --watch ./app & (npm run start && sleep 5 && npm run electron)",
1717
"both:dev": "npm run start & nodemon --watch ./electron --exec 'npm run electron'",
1818
"package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
1919
"create-installer-mac": "electron-installer-dmg ./release-builds/chronos-darwin-x64/chronos.app/ Chronos",

0 commit comments

Comments
 (0)