Skip to content

Commit cbe1449

Browse files
Fix the internal IPC to only subscribe to events once (#180)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent eeee277 commit cbe1449

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const path = require('path');
33
const {app, ipcMain, ipcRenderer, shell} = require('electron');
44
const Conf = require('conf');
55

6+
let isInitialized = false;
7+
68
// Set up the `ipcMain` handler for communication between renderer and main process.
79
const initDataListener = () => {
810
if (!ipcMain || !app) {
@@ -14,10 +16,16 @@ const initDataListener = () => {
1416
appVersion: app.getVersion()
1517
};
1618

19+
if (isInitialized) {
20+
return appData;
21+
}
22+
1723
ipcMain.on('electron-store-get-data', event => {
1824
event.returnValue = appData;
1925
});
2026

27+
isInitialized = true;
28+
2129
return appData;
2230
};
2331

0 commit comments

Comments
 (0)