bugfixing

This commit is contained in:
2021-06-13 23:18:47 +02:00
parent 4b931c06d8
commit 0d91060117
5 changed files with 24 additions and 60 deletions

View File

@@ -5,12 +5,18 @@ import {ShowSong} from './show-song';
import {SongDataService} from '../../songs/services/song-data.service';
import {first, take} from 'rxjs/operators';
import {UserService} from '../../../services/user/user.service';
import {ShowService} from './show.service';
@Injectable({
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,
private showService: ShowService
) {}
public async new$(showId: string, songId: string, addedLive = false): Promise<string | null> {
const song = await this.songDataService.read$(songId).pipe(take(1)).toPromise();
@@ -32,6 +38,15 @@ export class ShowSongService {
public list$ = (showId: string): Observable<ShowSong[]> => this.showSongDataService.list$(showId);
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 async delete$(showId: string, songId: string, index: number): Promise<void> {
await this.showSongDataService.delete(showId, songId);
const show = await this.showService.read$(showId).pipe(first()).toPromise();
if (!show) return;
const order = show.order;
order.splice(index, 1);
await this.showService.update$(showId, {order});
}
public update$ = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.showSongDataService.update$(showId, songId, data);
}