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

@@ -10,17 +10,14 @@ import {UserService} from '../../../services/user/user.service';
providedIn: 'root',
})
export class ShowSongService {
public constructor(
private showSongDataService: ShowSongDataService,
private songDataService: SongDataService,
private userService: UserService
) {}
public constructor(private showSongDataService: ShowSongDataService, private songDataService: SongDataService, private userService: UserService) {}
public async new$(showId: string, songId: string, order: number, addedLive = false): Promise<string | null> {
const song = await this.songDataService.read$(songId).pipe(take(1)).toPromise();
const user = await this.userService.user$.pipe(take(1)).toPromise();
if (!song || !user) return null;
const data: Partial<ShowSong> = {
...song,
songId,
order,
key: song.key,
@@ -31,10 +28,11 @@ export class ShowSongService {
return await this.showSongDataService.add(showId, data);
}
public list$ = (showId: string): Observable<ShowSong[]> =>
this.showSongDataService.list$(showId, _ => _.orderBy('order'));
public read$ = (showId: string, songId: string): Observable<ShowSong | null> => this.showSongDataService.read$(showId, songId);
public read = (showId: string, songId: string): Promise<ShowSong | null> => this.read$(showId, songId).pipe(first()).toPromise();
public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId, _ => _.orderBy('order'));
public list = (showId: string): Promise<ShowSong[]> => this.list$(showId).pipe(first()).toPromise();
public delete$ = (showId: string, songId: string): Promise<void> => this.showSongDataService.delete(showId, songId);
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> =>
await this.showSongDataService.update$(showId, songId, data);
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data);
}