persisting songs ins show

This commit is contained in:
2021-06-12 22:02:11 +02:00
parent 133844c889
commit 7cc905449c
23 changed files with 61 additions and 193 deletions

View File

@@ -1,43 +1,26 @@
import {Component, OnInit} from '@angular/core';
import {Component} from '@angular/core';
import {SongService} from '../songs/services/song.service';
import {GlobalSettingsService} from '../../services/global-settings.service';
import {Observable} from 'rxjs';
import {filter, map, switchMap} from 'rxjs/operators';
import {ShowSongService} from '../shows/services/show-song.service';
import {GlobalSettings} from '../../services/global-settings';
import {Song} from '../songs/services/song';
@Component({
selector: 'app-guest',
templateUrl: './guest.component.html',
styleUrls: ['./guest.component.less'],
})
export class GuestComponent implements OnInit {
public songs$: Observable<Observable<string>[]> | null = null;
export class GuestComponent {
public songs$: Observable<string[]> = this.globalSettingsService.get$.pipe(
filter(_ => !!_),
map(_ => _ as GlobalSettings),
map(_ => _.currentShow),
switchMap(_ => this.showSongService.list$(_)),
filter(_ => !!_),
map(_ => _),
map(_ => _.sort((x, y) => x.order - y.order).map(showSong => showSong.text))
);
public constructor(
private songService: SongService,
private globalSettingsService: GlobalSettingsService,
private showSongService: ShowSongService
) {}
public ngOnInit(): void {
this.songs$ = this.globalSettingsService.get$.pipe(
filter(_ => !!_),
map(_ => _ as GlobalSettings),
map(_ => _.currentShow),
switchMap(_ => this.showSongService.list$(_)),
filter(_ => !!_),
map(_ => _),
map(_ =>
_.sort((x, y) => x.order - y.order).map(showSong =>
this.songService.read$(showSong.songId).pipe(
filter(_ => !!_),
map(_ => _ as Song),
map(song => song.text)
)
)
)
);
}
public constructor(private songService: SongService, private globalSettingsService: GlobalSettingsService, private showSongService: ShowSongService) {}
}