From fb507b932a9814b9c3139a2ba2e1412806353ef6 Mon Sep 17 00:00:00 2001 From: 4gray Date: Tue, 9 Sep 2025 09:18:31 +0200 Subject: [PATCH] feat(m3u): preserve favorites list after updating playlist --- .../channel-list-container.component.ts | 11 +++++++---- .../video-player/toolbar/toolbar.component.html | 2 +- src/app/services/playlists.service.ts | 1 + src/app/state/reducers.ts | 10 ++++++---- 4 files changed, 15 insertions(+), 9 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 b10c54ca2..c83ec4aa4 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 @@ -4,7 +4,7 @@ import { moveItemInArray, } from '@angular/cdk/drag-drop'; import { ScrollingModule } from '@angular/cdk/scrolling'; -import { CommonModule, TitleCasePipe, KeyValue } from '@angular/common'; +import { CommonModule, KeyValue, TitleCasePipe } from '@angular/common'; import { Component, ElementRef, @@ -112,7 +112,7 @@ export class ChannelListContainerComponent { ) => favoriteChannelIds.map((favoriteChannelId) => this.channelList.find( - (channel) => channel.id === favoriteChannelId + (channel) => channel.url === favoriteChannelId ) ) ) @@ -172,7 +172,10 @@ export class ChannelListContainerComponent { this.store.dispatch(PlaylistActions.setChannels({ channels: [] })); } - groupsComparator = (a: KeyValue, b: KeyValue): number => { + groupsComparator = ( + a: KeyValue, + b: KeyValue + ): number => { const numA = parseInt(a.key.replace(/\D/g, '')); const numB = parseInt(b.key.replace(/\D/g, '')); @@ -181,5 +184,5 @@ export class ChannelListContainerComponent { } return a.key.localeCompare(b.key); - } + }; } diff --git a/src/app/player/components/video-player/toolbar/toolbar.component.html b/src/app/player/components/video-player/toolbar/toolbar.component.html index e5977b9c1..8fd47f7bf 100644 --- a/src/app/player/components/video-player/toolbar/toolbar.component.html +++ b/src/app/player/components/video-player/toolbar/toolbar.component.html @@ -15,7 +15,7 @@ > {{ - (favorites$ | async).includes(activeChannel?.id) + (favorites$ | async).includes(activeChannel?.url) ? 'star' : 'star_outline' }} id !== channel.id), + ...playlistFavorites.filter((url) => url !== channel.url), ]; } else { - favorites = [...playlistFavorites, channel.id]; + favorites = [...playlistFavorites, channel.url]; } return { ...state, @@ -123,9 +123,11 @@ export const playlistReducer = createReducer( ...action.playlist, _id: action.playlistId, updateDate: Date.now(), - favorites: [], count: action.playlist.playlist.items.length, userAgent: action.playlist.userAgent, + favorites: + state.playlists.entities[action.playlistId] + .favorites ?? [], }, }, state.playlists