mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 09:01:03 -08:00
refactor: remove ipcRenderer listeners on destroy
This commit is contained in:
2 files changed
+14
-2
No files matched your search
@@ -20,6 +20,7 @@ export class ElectronServiceStub {
|
||||
ipcRenderer = {
|
||||
send: jest.fn(),
|
||||
on: jest.fn(),
|
||||
removeAllListeners: jest.fn(),
|
||||
};
|
||||
remote = {
|
||||
process: {
|
||||
|
||||
@@ -135,13 +135,15 @@ export class HomeComponent {
|
||||
* @param playlist playlist object
|
||||
*/
|
||||
setPlaylist(playlist: Playlist): void {
|
||||
this.channelStore.reset();
|
||||
this.channelStore.remove();
|
||||
const favorites = playlist.favorites || [];
|
||||
const channels = playlist.playlist.items.map((element) =>
|
||||
createChannel(element)
|
||||
);
|
||||
this.channelStore.upsertMany(channels);
|
||||
this.channelStore.update(() => ({
|
||||
this.channelStore.update((store) => ({
|
||||
...store,
|
||||
active: undefined,
|
||||
favorites,
|
||||
playlistId: playlist.id,
|
||||
}));
|
||||
@@ -190,4 +192,13 @@ export class HomeComponent {
|
||||
duration,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove ipcRenderer listeners after component destroy
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.commandsList.forEach((command) =>
|
||||
this.electronService.ipcRenderer.removeAllListeners(command.id)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user