From b82fa5cc4a0634e54675294ae65ca379d49a9ebf Mon Sep 17 00:00:00 2001 From: 4gray Date: Wed, 27 Nov 2024 21:25:30 +0100 Subject: [PATCH] refactor: fix drag&drop in favorites list, simplify template Refactor the channel list component to improve readability and maintainability. Remove unnecessary and streamline the template structure by using Angular's structural directives. This enhances the clarity of the code and reduces complexity in the HTML markup. --- .../channel-list-container.component.html | 181 +++++++++--------- .../channel-list-container.component.ts | 17 +- 2 files changed, 104 insertions(+), 94 deletions(-) diff --git a/src/app/player/components/channel-list-container/channel-list-container.component.html b/src/app/player/components/channel-list-container/channel-list-container.component.html index 563f79ae7..ac4539969 100644 --- a/src/app/player/components/channel-list-container/channel-list-container.component.html +++ b/src/app/player/components/channel-list-container/channel-list-container.component.html @@ -57,100 +57,105 @@ - - - - {{ - groups.key || - ('CHANNELS.UNGROUPED' | translate) - | titlecase - }} - ({{ groups.value.length }}) - - - - - - - - + > + + + + + } + } - - - star -
- {{ 'CHANNELS.FAVORITES' | translate }} -
-
- - - - - - {{ - 'CHANNELS.NO_FAVORITES' | translate - }} - - {{ - 'CHANNELS.USE_STAR_TO_FAVORITE' | translate - }} + @let showFavorites = (playlistId$ | async) !== 'GLOBAL_FAVORITES'; + @if (showFavorites) { + + + star +
+ {{ 'CHANNELS.FAVORITES' | translate }} +
-
-
+ @let favorites = favorites$ | async; + @if (favorites) { + + @if (favorites.length > 0) { + + } @else { + {{ + 'CHANNELS.NO_FAVORITES' | translate + }} + + {{ + 'CHANNELS.USE_STAR_TO_FAVORITE' | translate + }} + } + + } + + } } @else { No channels there 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 bd9540891..12d959cf0 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 @@ -1,4 +1,8 @@ -import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; +import { + CdkDragDrop, + DragDropModule, + moveItemInArray, +} from '@angular/cdk/drag-drop'; import { ScrollingModule } from '@angular/cdk/scrolling'; import { CommonModule, TitleCasePipe } from '@angular/common'; import { @@ -37,8 +41,11 @@ import { ChannelListItemComponent } from './channel-list-item/channel-list-item. templateUrl: './channel-list-container.component.html', styleUrls: ['./channel-list-container.component.scss'], imports: [ - CommonModule, ChannelListItemComponent, + CommonModule, + DragDropModule, + FilterPipe, + FormsModule, MatDividerModule, MatExpansionModule, MatFormFieldModule, @@ -46,11 +53,9 @@ import { ChannelListItemComponent } from './channel-list-item/channel-list-item. MatInputModule, MatListModule, MatTabsModule, - TranslateModule, - TitleCasePipe, - FilterPipe, - FormsModule, ScrollingModule, + TitleCasePipe, + TranslateModule, ], }) export class ChannelListContainerComponent {