Skip to content

Commit

Permalink
unsub to listeners on bootstrap unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed Jun 3, 2024
1 parent 90d7ca6 commit 4926cdc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/app/components/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ const Bootsrap: React.FC = () => {
.catch((err: unknown) => {
console.error(err);
});

return () => {
window.api.removeAllListeners("VuMeter");
window.api.removeAllListeners("station-transceivers-updated");
window.api.removeAllListeners("station-data-received");
window.api.removeAllListeners("FrequencyRxBegin");
window.api.removeAllListeners("StationRxBegin");
window.api.removeAllListeners("FrequencyRxEnd");
window.api.removeAllListeners("PttState");
window.api.removeAllListeners("error");
window.api.removeAllListeners("VoiceConnected");
window.api.removeAllListeners("VoiceDisconnected");
window.api.removeAllListeners("network-connected");
window.api.removeAllListeners("network-disconnected");
window.api.removeAllListeners("ptt-key-set");
}
}, []);

return null;
Expand Down
3 changes: 3 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const IElectronAPI = {
listener(...args);
});
},
removeAllListeners: (channel: string) => {
ipcRenderer.removeAllListeners(channel);
},

setAlwaysOnTop: (state: boolean) => {
ipcRenderer.send("set-always-on-top", state);
Expand Down

0 comments on commit 4926cdc

Please sign in to comment.