Skip to content

Commit

Permalink
Fix the internal IPC to only subscribe to events once (#180)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
rroessler and sindresorhus authored Apr 7, 2021
1 parent eeee277 commit cbe1449
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const path = require('path');
const {app, ipcMain, ipcRenderer, shell} = require('electron');
const Conf = require('conf');

let isInitialized = false;

// Set up the `ipcMain` handler for communication between renderer and main process.
const initDataListener = () => {
if (!ipcMain || !app) {
Expand All @@ -14,10 +16,16 @@ const initDataListener = () => {
appVersion: app.getVersion()
};

if (isInitialized) {
return appData;
}

ipcMain.on('electron-store-get-data', event => {
event.returnValue = appData;
});

isInitialized = true;

return appData;
};

Expand Down

0 comments on commit cbe1449

Please sign in to comment.