mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix: preserve page state on back navigation and sort downloads by newest
- Only reset page to 0 when category actually changes in setSelectedCategory - Preserve current page when navigating back from VOD/series details - Sort downloads list by createdAt descending (newest first) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
229392d5b0
commit
83d031c3b0
2 files changed
+23
-8
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user