mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
feat: implement category scroll restoration in live stream layout
This commit is contained in:
1 parent
2691e3f36e
commit
e8632e7bee
1 file changed
+26
-1
@@ -1,9 +1,13 @@
|
||||
import {
|
||||
afterNextRender,
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
computed,
|
||||
ElementRef,
|
||||
inject,
|
||||
Injector,
|
||||
OnInit,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatIconButton } from '@angular/material/button';
|
||||
@@ -23,7 +27,9 @@ import {
|
||||
CategoryManagementDialogComponent,
|
||||
CategoryManagementDialogData,
|
||||
} from '../category-management-dialog/category-management-dialog.component';
|
||||
import { CategoryViewComponent } from '../category-view/category-view.component';
|
||||
import {
|
||||
CategoryViewComponent,
|
||||
} from '../category-view/category-view.component';
|
||||
import { PortalChannelsListComponent } from '../portal-channels-list/portal-channels-list.component';
|
||||
import { FavoritesService } from '../services/favorites.service';
|
||||
import { XtreamStore } from '../stores/xtream.store';
|
||||
@@ -80,6 +86,12 @@ export class LiveStreamLayoutComponent implements OnInit {
|
||||
};
|
||||
});
|
||||
|
||||
private readonly injector = inject(Injector);
|
||||
private readonly categoryView = viewChild(CategoryViewComponent, {
|
||||
read: ElementRef,
|
||||
});
|
||||
private categoryScrollTop = 0;
|
||||
|
||||
readonly player = this.settingsStore.player;
|
||||
streamUrl: string;
|
||||
favorites = new Map<number, boolean>();
|
||||
@@ -116,12 +128,25 @@ export class LiveStreamLayoutComponent implements OnInit {
|
||||
}
|
||||
|
||||
selectCategory(category: XtreamCategory) {
|
||||
const el = this.categoryView()?.nativeElement;
|
||||
if (el) {
|
||||
this.categoryScrollTop = el.scrollTop;
|
||||
}
|
||||
const categoryId = (category as any).category_id ?? category.id;
|
||||
this.xtreamStore.setSelectedCategory(categoryId);
|
||||
}
|
||||
|
||||
backToCategories() {
|
||||
this.xtreamStore.setSelectedCategory(null);
|
||||
afterNextRender(
|
||||
() => {
|
||||
const el = this.categoryView()?.nativeElement;
|
||||
if (el) {
|
||||
el.scrollTop = this.categoryScrollTop;
|
||||
}
|
||||
},
|
||||
{ injector: this.injector }
|
||||
);
|
||||
}
|
||||
|
||||
openCategoryManagement(): void {
|
||||
|
||||
Reference in new issue
Block a user