mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 09:01:03 -08:00
feat(m3u): preserve favorites list after updating playlist
This commit is contained in:
1 parent
89316477be
commit
fb507b932a
4 files changed
+15
-9
No files matched your search
+7
-4
@@ -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<string, any[]>, b: KeyValue<string, any[]>): number => {
|
||||
groupsComparator = (
|
||||
a: KeyValue<string, any[]>,
|
||||
b: KeyValue<string, any[]>
|
||||
): 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
>
|
||||
<mat-icon>
|
||||
{{
|
||||
(favorites$ | async).includes(activeChannel?.id)
|
||||
(favorites$ | async).includes(activeChannel?.url)
|
||||
? 'star'
|
||||
: 'star_outline'
|
||||
}}</mat-icon
|
||||
|
||||
@@ -73,6 +73,7 @@ export class PlaylistsService {
|
||||
count: updatedPlaylist.playlist.items.length,
|
||||
updateDate: Date.now(),
|
||||
updateState: PlaylistUpdateState.UPDATED,
|
||||
favorites: currentPlaylist.favorites,
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@@ -58,12 +58,12 @@ export const playlistReducer = createReducer(
|
||||
const { channel } = action;
|
||||
const playlistFavorites =
|
||||
state.playlists.entities[state.playlists.selectedId].favorites;
|
||||
if (playlistFavorites.includes(channel.id)) {
|
||||
if (playlistFavorites.includes(channel.url)) {
|
||||
favorites = [
|
||||
...playlistFavorites.filter((id) => 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
|
||||
|
||||
Reference in new issue
Block a user