diff --git a/apps/web/src/app/xtream-tauri/downloads/downloads.component.ts b/apps/web/src/app/xtream-tauri/downloads/downloads.component.ts index 091b1d82d..09e9b10c3 100644 --- a/apps/web/src/app/xtream-tauri/downloads/downloads.component.ts +++ b/apps/web/src/app/xtream-tauri/downloads/downloads.component.ts @@ -40,11 +40,19 @@ export class DownloadsComponent implements OnInit { readonly hasDownloads = this.downloadsService.hasDownloads; readonly activeCount = this.downloadsService.activeCount; - /** Filter downloads for current playlist */ + /** Filter downloads for current playlist and sort by newest first */ readonly filteredDownloads = computed(() => { const playlistId = this.route.snapshot.params['id']; - if (!playlistId) return this.downloads(); - return this.downloads().filter((d) => d.playlistId === playlistId); + const downloads = playlistId + ? this.downloads().filter((d) => d.playlistId === playlistId) + : this.downloads(); + + // Sort by createdAt descending (newest first) + return [...downloads].sort((a, b) => { + const dateA = a.createdAt ? new Date(a.createdAt).getTime() : 0; + const dateB = b.createdAt ? new Date(b.createdAt).getTime() : 0; + return dateB - dateA; + }); }); ngOnInit() { diff --git a/apps/web/src/app/xtream-tauri/stores/features/with-selection.feature.ts b/apps/web/src/app/xtream-tauri/stores/features/with-selection.feature.ts index 760e7105b..0a6f509ac 100644 --- a/apps/web/src/app/xtream-tauri/stores/features/with-selection.feature.ts +++ b/apps/web/src/app/xtream-tauri/stores/features/with-selection.feature.ts @@ -278,13 +278,20 @@ export function withSelection() { /** * Set the selected category + * Only resets page to 0 when category actually changes */ setSelectedCategory(categoryId: number | null): void { - patchState(store, { - selectedCategoryId: - categoryId !== null ? Number(categoryId) : null, - page: 0, - }); + const newCategoryId = + categoryId !== null ? Number(categoryId) : null; + const currentCategoryId = store.selectedCategoryId(); + + // Only reset page if category actually changed + if (currentCategoryId !== newCategoryId) { + patchState(store, { + selectedCategoryId: newCategoryId, + page: 0, + }); + } }, /**