update angular
This commit is contained in:
@@ -33,8 +33,9 @@ export class DocxService {
|
||||
private songService: SongService,
|
||||
private textRenderingService: TextRenderingService,
|
||||
private userService: UserService,
|
||||
private configService: ConfigService
|
||||
) {}
|
||||
private configService: ConfigService,
|
||||
) {
|
||||
}
|
||||
|
||||
public async create(showId: string, options: DownloadOptions = {}): Promise<void> {
|
||||
const data = await this.prepareData(showId);
|
||||
@@ -94,7 +95,10 @@ export class DocxService {
|
||||
});
|
||||
}
|
||||
|
||||
private renderSongs(songs: {showSong: ShowSong; sections: Section[]}[], options: DownloadOptions, config: Config): Paragraph[] {
|
||||
private renderSongs(songs: {
|
||||
showSong: ShowSong;
|
||||
sections: Section[]
|
||||
}[], options: DownloadOptions, config: Config): Paragraph[] {
|
||||
return songs.reduce((p: Paragraph[], song) => [...p, ...this.renderSong(song.showSong, song.showSong, song.sections, options, config)], []);
|
||||
}
|
||||
|
||||
@@ -199,7 +203,10 @@ export class DocxService {
|
||||
sections,
|
||||
};
|
||||
});
|
||||
const songsLoaded = (await Promise.all(songsAsync)).filter(_ => !!_).map(_ => _ as {showSong: ShowSong; sections: Section[]});
|
||||
const songsLoaded = (await Promise.all(songsAsync)).filter(_ => !!_).map(_ => _ as {
|
||||
showSong: ShowSong;
|
||||
sections: Section[]
|
||||
});
|
||||
const songs = show.order.map(_ => songsLoaded.filter(f => f.showSong.id === _)[0]);
|
||||
return {songs, show, user, config};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {map} from 'rxjs/operators';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShowDataService {
|
||||
public list$ = new BehaviorSubject<Show[]>([]);
|
||||
private collection = 'shows';
|
||||
|
||||
public constructor(private dbService: DbService) {
|
||||
@@ -15,7 +16,7 @@ export class ShowDataService {
|
||||
}
|
||||
|
||||
public listRaw$ = () => this.dbService.col$<Show>(this.collection);
|
||||
public list$ = new BehaviorSubject<Show[]>([]);
|
||||
|
||||
public read$ = (showId: string): Observable<Show | null> => this.list$.pipe(map(_ => _.find(s => s.id === showId) || null));
|
||||
|
||||
// public list$ = (): Observable<Show[]> => this.dbService.col$(this.collection);
|
||||
|
||||
@@ -11,7 +11,8 @@ export class ShowSongDataService {
|
||||
private collection = 'shows';
|
||||
private subCollection = 'songs';
|
||||
|
||||
public constructor(private dbService: DbService) {}
|
||||
public constructor(private dbService: DbService) {
|
||||
}
|
||||
|
||||
public list$ = (showId: string, queryFn?: QueryFn): Observable<ShowSong[]> => this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryFn);
|
||||
public read$ = (showId: string, songId: string): Observable<ShowSong | null> => this.dbService.doc$(`${this.collection}/${showId}/${this.subCollection}/${songId}`);
|
||||
|
||||
@@ -14,8 +14,9 @@ export class ShowSongService {
|
||||
private showSongDataService: ShowSongDataService,
|
||||
private songDataService: SongDataService,
|
||||
private userService: UserService,
|
||||
private showService: ShowService
|
||||
) {}
|
||||
private showService: ShowService,
|
||||
) {
|
||||
}
|
||||
|
||||
public async new$(showId: string, songId: string, addedLive = false): Promise<string | null> {
|
||||
const song = await firstValueFrom(this.songDataService.read$(songId));
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('ShowService', () => {
|
||||
() =>
|
||||
void TestBed.configureTestingModule({
|
||||
providers: [{provide: ShowDataService, useValue: mockShowDataService}],
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
ShowService.SHOW_TYPE_PUBLIC.forEach(type => {
|
||||
|
||||
@@ -25,14 +25,14 @@ export class ShowService {
|
||||
return this.userService.user$.pipe(
|
||||
switchMap(
|
||||
() => this.showDataService.list$,
|
||||
(user: User | null, shows: Show[]) => ({user, shows})
|
||||
(user: User | null, shows: Show[]) => ({user, shows}),
|
||||
),
|
||||
map(s =>
|
||||
s.shows
|
||||
.sort((a, b) => a.date.toMillis() - b.date.toMillis())
|
||||
.filter(_ => !_.archived)
|
||||
.filter(show => show.published || (show.owner === s.user?.id && !publishedOnly))
|
||||
)
|
||||
.filter(show => show.published || (show.owner === s.user?.id && !publishedOnly)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user