diff --git a/src/app/modules/presentation/remote/remote.component.ts b/src/app/modules/presentation/remote/remote.component.ts
index d25f98b..82b14f4 100644
--- a/src/app/modules/presentation/remote/remote.component.ts
+++ b/src/app/modules/presentation/remote/remote.component.ts
@@ -3,7 +3,6 @@ import {combineLatest, Observable} from 'rxjs';
import {PresentationBackground, Show} from '../../shows/services/show';
import {ShowSongService} from '../../shows/services/show-song.service';
import {SongService} from '../../songs/services/song.service';
-import {Song} from '../../songs/services/song';
import {faDesktop} from '@fortawesome/free-solid-svg-icons';
import {ShowService} from '../../shows/services/show.service';
import {ShowSong} from '../../shows/services/show-song';
@@ -32,7 +31,7 @@ export class RemoteComponent {
public shows$: Observable
;
public show: Show | null = null;
public showSongs: ShowSong[] = [];
- public songs: Song[] = [];
+ public songs$ = this.songService.list$();
public presentationSongs: PresentationSong[] = [];
public currentShowId: string | null = null;
public progress = false;
@@ -55,7 +54,6 @@ export class RemoteComponent {
this.shows$ = showService
.list$(true)
.pipe(map(_ => _.filter(_ => _.date.toDate() > new Date(new Date().setMonth(new Date().getMonth() - 1))).sort((a, b) => (b.date < a.date ? -1 : b.date > a.date ? 1 : 0))));
- songService.list$().subscribe(_ => (this.songs = _));
globalSettingsService.get$
.pipe(
@@ -72,29 +70,28 @@ export class RemoteComponent {
}
public async onShowChanged(change: string, updateShow = true): Promise {
+ this.presentationSongs = [];
+ this.cRef.markForCheck();
+
if (updateShow) {
await this.globalSettingsService.set({currentShow: change});
await this.showService.update$(change, {presentationSongId: 'title'});
}
+
this.currentShowId = change;
- this.showService
- .read$(change)
- .pipe(debounceTime(10))
- .subscribe(show => {
- this.show = show;
- this.cRef.markForCheck();
- });
combineLatest([this.showService.read$(change), this.showSongService.list$(change)])
- .pipe(debounceTime(10))
+ .pipe(debounceTime(300))
.subscribe(([show, list]) => {
this.showSongs = list;
+ this.show = show;
const presentationSongs = list.map(song => ({
id: song.id,
title: song.title,
sections: this.textRenderingService.parse(song.text, null),
}));
this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? [];
+ this.cRef.markForCheck();
});
}
diff --git a/src/app/modules/shows/list/list.component.html b/src/app/modules/shows/list/list.component.html
index da78d80..1a958f7 100644
--- a/src/app/modules/shows/list/list.component.html
+++ b/src/app/modules/shows/list/list.component.html
@@ -8,7 +8,6 @@
0"
- @fade
[padding]="false"
heading="meine Veranstaltungen"
>
@@ -24,7 +23,6 @@
0"
- @fade
[padding]="false"
heading="veröffentlichte Veranstaltungen"
>
diff --git a/src/app/modules/shows/new/new.component.ts b/src/app/modules/shows/new/new.component.ts
index 180c237..a44f4a9 100644
--- a/src/app/modules/shows/new/new.component.ts
+++ b/src/app/modules/shows/new/new.component.ts
@@ -23,7 +23,7 @@ export class NewComponent implements OnInit {
public faSave = faSave;
public constructor(private showService: ShowService, showDataService: ShowDataService, private router: Router) {
- this.shows$ = showDataService.list$();
+ this.shows$ = showDataService.list$;
}
public ngOnInit(): void {
diff --git a/src/app/modules/shows/services/show-data.service.ts b/src/app/modules/shows/services/show-data.service.ts
index 07b1271..2116c8b 100644
--- a/src/app/modules/shows/services/show-data.service.ts
+++ b/src/app/modules/shows/services/show-data.service.ts
@@ -1,8 +1,8 @@
import {Injectable} from '@angular/core';
-import {Observable} from 'rxjs';
+import {BehaviorSubject, Observable} from 'rxjs';
import {DbService} from '../../../services/db.service';
import {Show} from './show';
-import {QueryFn} from '@angular/fire/compat/firestore/interfaces';
+import {map} from 'rxjs/operators';
@Injectable({
providedIn: 'root',
@@ -10,10 +10,15 @@ import {QueryFn} from '@angular/fire/compat/firestore/interfaces';
export class ShowDataService {
private collection = 'shows';
- public constructor(private dbService: DbService) {}
+ public constructor(private dbService: DbService) {
+ this.dbService.col$(this.collection).subscribe(_ => this.list$.next(_));
+ }
- public list$ = (queryFn?: QueryFn): Observable => this.dbService.col$(this.collection, queryFn);
- public read$ = (showId: string): Observable => this.dbService.doc$(`${this.collection}/${showId}`);
+ public list$ = new BehaviorSubject([]);
+ public read$ = (showId: string): Observable => this.list$.pipe(map(_ => _.find(s => s.id === showId) || null));
+
+ // public list$ = (): Observable => this.dbService.col$(this.collection);
+ // public read$ = (showId: string): Observable => this.dbService.doc$(`${this.collection}/${showId}`);
public update = async (showId: string, data: Partial): Promise => await this.dbService.doc(`${this.collection}/${showId}`).update(data);
public add = async (data: Partial): Promise => (await this.dbService.col(this.collection).add(data)).id;
}
diff --git a/src/app/modules/shows/services/show.service.ts b/src/app/modules/shows/services/show.service.ts
index 389da90..57c96d0 100644
--- a/src/app/modules/shows/services/show.service.ts
+++ b/src/app/modules/shows/services/show.service.ts
@@ -24,7 +24,7 @@ export class ShowService {
public list$(publishedOnly = false): Observable {
return this.userService.user$.pipe(
switchMap(
- () => this.showDataService.list$(),
+ () => this.showDataService.list$,
(user: User | null, shows: Show[]) => ({user, shows})
),
map(s => s.shows.filter(_ => !_.archived).filter(show => show.published || (show.owner === s.user?.id && !publishedOnly)))
diff --git a/src/app/modules/songs/song-list/song-list.component.html b/src/app/modules/songs/song-list/song-list.component.html
index d536b74..6140f37 100644
--- a/src/app/modules/songs/song-list/song-list.component.html
+++ b/src/app/modules/songs/song-list/song-list.component.html
@@ -1,4 +1,4 @@
-