I am experiencing a strange issue with my back-end notification system and client-side Angular Material dialog component. There are times when the dialog does not fully instantiate, even though the constructor of the component is invoked. The component's lifecycle methods are not called until the dialog closes, leading to inconsistency. Occasionally, everything works fine and ngOnInit is also triggered.
The component handling the ipc subscription has been configured like this (I have experimented with using setTimeout and Observable as well, but with limited success):
api.receive('hotkey', (event, arg) => {
this.onHotkey(shortcut as Shortcut);
});
api.send('setHotkeyListener');
The hotkey functionality triggers the same method as a button, which ultimately calls this.dialog.open(...) method.
The API setup involves a contextBridge in preload.js:
const {
contextBridge,
ipcRenderer
} = require("electron");
// Expose protected methods for renderer process to interact with ipcRenderer
contextBridge.exposeInMainWorld(
"api", {
sendSync: (channel, data) => {
return ipcRenderer.sendSync(channel, data);
},
send: (channel, data) => {
ipcRenderer.send(channel, data);
},
receive: (channel, func) => {
ipcRenderer.on(channel, (...args) => func(...args));
}
}
);
I suspect that there might be a missing context causing Angular to not receive necessary information from the ipcRenderer code path. Do you have any insights on what could be missing?