mirror of
https://github.com/xodio/xod.git
synced 2026-03-25 01:56:54 +01:00
fix(xod-client-electron): do not send data through IPC to the renderer if it was destroyed
This commit is contained in:
@@ -6,7 +6,17 @@ import { errorToPlainObject } from './utils';
|
||||
export default (fn, eventName) => {
|
||||
const STATES = getAllStatesForEvent(eventName);
|
||||
ipcMain.on(STATES.BEGIN, (event, payload) => {
|
||||
const onProgress = data => event.sender.send(STATES.PROCESS, data);
|
||||
// Prevent sending data to the closed window
|
||||
// because it produces an exception
|
||||
if (event.sender.isDestroyed()) return;
|
||||
|
||||
const onProgress = data => {
|
||||
// Prevent sending data to the closed window
|
||||
// because it produces an exception
|
||||
if (event.sender.isDestroyed()) return;
|
||||
|
||||
event.sender.send(STATES.PROCESS, data);
|
||||
};
|
||||
|
||||
fn(event, payload, onProgress)
|
||||
.then(res => event.sender.send(STATES.COMPLETE, res))
|
||||
|
||||
Reference in New Issue
Block a user