From bb23e834fe7257bcb71fbe20e8f3f8ff79dd6ca0 Mon Sep 17 00:00:00 2001 From: 4gray Date: Wed, 25 Dec 2024 21:06:52 +0100 Subject: [PATCH] fix(epg): prefer channel.tgv.id for epg match --- .../channel-list-container.component.ts | 2 +- .../multi-epg-container.component.ts | 52 +++++++++++-------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/app/player/components/channel-list-container/channel-list-container.component.ts b/src/app/player/components/channel-list-container/channel-list-container.component.ts index 12d959cf0..9fb3bb34a 100644 --- a/src/app/player/components/channel-list-container/channel-list-container.component.ts +++ b/src/app/player/components/channel-list-container/channel-list-container.component.ts @@ -134,7 +134,7 @@ export class ChannelListContainerComponent { this.selected = channel; this.store.dispatch(PlaylistActions.setActiveChannel({ channel })); - const epgChannelId = channel?.tvg?.id || channel?.name; + const epgChannelId = channel?.tvg?.id?.trim() || channel?.name.trim(); if (epgChannelId) { this.epgService.getChannelPrograms(epgChannelId); diff --git a/src/app/player/components/multi-epg/multi-epg-container.component.ts b/src/app/player/components/multi-epg/multi-epg-container.component.ts index 81cac66f0..628cfeaf1 100644 --- a/src/app/player/components/multi-epg/multi-epg-container.component.ts +++ b/src/app/player/components/multi-epg/multi-epg-container.component.ts @@ -114,19 +114,28 @@ export class MultiEpgContainerComponent requestAnimationFrame(() => { const container = document.getElementById('epg-container'); if (container) { - container.scrollTo(scrollPosition < 1000 ? 0 : scrollPosition - 150, 0); + container.scrollTo( + scrollPosition < 1000 ? 0 : scrollPosition - 150, + 0 + ); } }); } private initializeVisibleChannels(): void { if (this.epgContainer) { - const containerHeight = this.epgContainer.nativeElement.offsetHeight; - const calculatedVisibleChannels = Math.floor((containerHeight - this.barHeight) / this.barHeight); - - this.visibleChannels = Math.max(10, Math.min(calculatedVisibleChannels, 20)); + const containerHeight = + this.epgContainer.nativeElement.offsetHeight; + const calculatedVisibleChannels = Math.floor( + (containerHeight - this.barHeight) / this.barHeight + ); + + this.visibleChannels = Math.max( + 10, + Math.min(calculatedVisibleChannels, 20) + ); this.channelsUpperRange = this.visibleChannels; - + console.log('Container height:', containerHeight); console.log('Calculated visible channels:', this.visibleChannels); } @@ -153,8 +162,11 @@ export class MultiEpgContainerComponent try { const channelNames = this._playlistChannels - .map((channel) => channel.name?.trim() ?? '') - .filter((name) => name !== ''); + .map( + (channel) => + channel.tvg?.id?.trim() ?? channel.name?.trim() ?? '' + ) + .filter((name) => name !== ''); console.log('Requesting EPG data:'); console.log('- Skip:', this.channelsLowerRange); @@ -176,7 +188,7 @@ export class MultiEpgContainerComponent // Update isLastPage based on the number of channels received this.isLastPage = response.length < this.visibleChannels; - + this.cdr.detectChanges(); } } catch (error) { @@ -185,24 +197,20 @@ export class MultiEpgContainerComponent } nextChannels(): void { - console.log('Next channels clicked'); - console.log('Current range:', this.channelsLowerRange, 'to', this.channelsUpperRange); - this.channelsLowerRange += this.visibleChannels; - this.channelsUpperRange = this.channelsLowerRange + this.visibleChannels; - - console.log('New range:', this.channelsLowerRange, 'to', this.channelsUpperRange); + this.channelsUpperRange = + this.channelsLowerRange + this.visibleChannels; + this.requestPrograms(); } previousChannels(): void { - console.log('Previous channels clicked'); - console.log('Current range:', this.channelsLowerRange, 'to', this.channelsUpperRange); - - this.channelsLowerRange = Math.max(0, this.channelsLowerRange - this.visibleChannels); - this.channelsUpperRange = this.channelsLowerRange + this.visibleChannels; - - console.log('New range:', this.channelsLowerRange, 'to', this.channelsUpperRange); + this.channelsLowerRange = Math.max( + 0, + this.channelsLowerRange - this.visibleChannels + ); + this.channelsUpperRange = + this.channelsLowerRange + this.visibleChannels; this.requestPrograms(); }