fix: use specific listener cleanup instead of removeAllListeners

Return unsubscribe function from onPlaybackPositionUpdate to ensure
only the specific listener is removed on destroy, preventing issues
with multiple store instances.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Opus 4.5 committed 2026-01-22 13:32:04 +01:00
1 parent 0219d3253e
commit 9cd278256b
3 files changed
+34 -34

No files matched your search

@@ -28,15 +28,12 @@ contextBridge.exposeInMainWorld('electron', {
) => {
ipcRenderer.on('EPG_PROGRESS_UPDATE', (_event, data) => callback(data));
},
// Playback position update listener
// Playback position update listener - returns unsubscribe function
onPlaybackPositionUpdate: (callback: (data: any) => void) => {
ipcRenderer.on('playback-position-update', (_event, data) =>
callback(data)
);
},
// Remove playback position listener
removePlaybackPositionListener: () => {
ipcRenderer.removeAllListeners('playback-position-update');
const handler = (_event: Electron.IpcRendererEvent, data: any) =>
callback(data);
ipcRenderer.on('playback-position-update', handler);
return () => ipcRenderer.off('playback-position-update', handler);
},
// DB save content progress listener
onDbSaveContentProgress: (callback: (count: number) => void) => {