From 23767e3a7660d4e3d3e4c2f3546b32aa05208bbe Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 29 Mar 2026 00:56:57 +0100 Subject: [PATCH] refactor(recent-playlists): simplify template structure and remove unused imports --- .../recent-playlists.component.html | 109 +++++++----------- .../recent-playlists.component.ts | 13 ++- 2 files changed, 47 insertions(+), 75 deletions(-) diff --git a/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.html b/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.html index c06181745..eb0f576e1 100644 --- a/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.html +++ b/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.html @@ -1,73 +1,44 @@ -@if (allPlaylistsLoaded()) { - @defer { - @if (playlistsData$ | async; as data) { - @if (data.playlists.length === 0) { - @if (data.totalCount === 0) { - - - } @else { - - - } - } @else { - - @for ( - item of data.playlists; - track item._id; - let last = $last - ) { - - } - - } +@if (playlistsData(); as data) { + @if (data.playlists.length === 0) { + @if (data.totalCount === 0) { + + + } @else { + + } - } @placeholder { -
- @for (a of ghostElements; track $index) { -
- -
- - -
-
- -
-
+ } @else { + + @for ( + item of data.playlists; + track item._id; + let last = $last + ) { + } -
+ } } diff --git a/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.ts b/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.ts index 39e8e3422..9db689d7c 100644 --- a/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.ts +++ b/libs/playlist/shared/ui/src/lib/recent-playlists/recent-playlists.component.ts @@ -3,7 +3,6 @@ import { DragDropModule, moveItemInArray, } from '@angular/cdk/drag-drop'; -import { AsyncPipe } from '@angular/common'; import { Component, effect, inject, input, output, signal } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; import { MatDialog } from '@angular/material/dialog'; @@ -20,7 +19,6 @@ import { selectAllPlaylistsMeta, selectPlaylistsLoadingFlag, } from 'm3u-state'; -import { NgxSkeletonLoaderComponent } from 'ngx-skeleton-loader'; import { BehaviorSubject, combineLatest, map } from 'rxjs'; import { DialogService } from 'components'; import { @@ -51,12 +49,10 @@ type PlaylistBusyOperation = { templateUrl: './recent-playlists.component.html', styleUrls: ['./recent-playlists.component.scss'], imports: [ - AsyncPipe, DragDropModule, EmptyStateComponent, MatInputModule, MatListModule, - NgxSkeletonLoaderComponent, PlaylistItemComponent, ], }) @@ -97,8 +93,6 @@ export class RecentPlaylistsComponent { new Map() ); - readonly ghostElements = new Array(10); - constructor() { // Update searchQuery when input changes effect(() => { @@ -154,6 +148,13 @@ export class RecentPlaylistsComponent { }) ); + readonly playlistsData = toSignal(this.playlistsData$, { + initialValue: { + playlists: [] as PlaylistMeta[], + totalCount: 0, + }, + }); + /** * Opens the details dialog with the information about the provided playlist * @param data selected playlist