fix scroll position
This commit is contained in:
@@ -11,13 +11,20 @@ export class SongDataService {
|
||||
private dbService = inject(DbService);
|
||||
|
||||
private collection = 'songs';
|
||||
public list$: Observable<Song[]> = this.dbService.col$<Song>(this.collection).pipe(
|
||||
private loadedList$: Observable<Song[]> = this.dbService.col$<Song>(this.collection).pipe(
|
||||
shareReplay({
|
||||
bufferSize: 1,
|
||||
refCount: false, // keep the listener alive after first subscription to avoid reloading on navigation
|
||||
})
|
||||
);
|
||||
public list$: Observable<Song[]> = this.loadedList$.pipe(
|
||||
startWith([] as Song[]), // immediate empty emit keeps UI responsive while first snapshot arrives
|
||||
shareReplay({
|
||||
bufferSize: 1,
|
||||
refCount: false, // keep the listener alive after first subscription to avoid reloading on navigation
|
||||
})
|
||||
);
|
||||
public listLoaded$ = (): Observable<Song[]> => this.loadedList$;
|
||||
|
||||
public read$ = (songId: string): Observable<Song | null> => this.dbService.doc$(this.collection + '/' + songId);
|
||||
public update$ = async (songId: string, data: Partial<Song>): Promise<void> => await this.dbService.doc(this.collection + '/' + songId).update(data);
|
||||
|
||||
@@ -12,6 +12,6 @@ export class SongListResolver {
|
||||
private songService = inject(SongService);
|
||||
|
||||
public resolve(): Observable<Song[]> {
|
||||
return this.songService.list$().pipe(take(1));
|
||||
return this.songService.listLoaded$().pipe(take(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export class SongService {
|
||||
public static LEGAL_TYPE: SongLegalType[] = ['open', 'allowed'];
|
||||
|
||||
public list$ = (): Observable<Song[]> => this.songDataService.list$; //.pipe(tap(_ => (this.list = _)));
|
||||
public listLoaded$ = (): Observable<Song[]> => this.songDataService.listLoaded$();
|
||||
public read$ = (songId: string): Observable<Song | null> => this.songDataService.read$(songId);
|
||||
public read = (songId: string): Promise<Song | null> => firstValueFrom(this.read$(songId));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user