optimize remote load

This commit is contained in:
2022-11-09 23:31:51 +01:00
parent 0f26e6b699
commit 898587bbbd
2 changed files with 15 additions and 18 deletions

View File

@@ -62,7 +62,7 @@ export class MonitorComponent implements OnInit {
this.presentationBackground = _.presentationBackground; this.presentationBackground = _.presentationBackground;
this.zoom = _.presentationZoom ?? 30; this.zoom = _.presentationZoom ?? 30;
if (this.songId !== _.presentationSongId) this.songId = 'empty'; if (this.songId !== _.presentationSongId) this.songId = 'empty';
setTimeout(() => (this.songId = _.presentationSongId), 300); setTimeout(() => (this.songId = _.presentationSongId), 600);
}), }),
switchMap((_: Show) => this.showSongService.read$(_.id, _.presentationSongId)), switchMap((_: Show) => this.showSongService.read$(_.id, _.presentationSongId)),
filter(_ => !!_), filter(_ => !!_),

View File

@@ -1,4 +1,4 @@
import {Component} from '@angular/core'; import {ChangeDetectionStrategy, Component} from '@angular/core';
import {combineLatest, Observable} from 'rxjs'; import {combineLatest, Observable} from 'rxjs';
import {PresentationBackground, Show} from '../../shows/services/show'; import {PresentationBackground, Show} from '../../shows/services/show';
import {ShowSongService} from '../../shows/services/show-song.service'; import {ShowSongService} from '../../shows/services/show-song.service';
@@ -11,7 +11,6 @@ import {GlobalSettingsService} from '../../../services/global-settings.service';
import {UntypedFormControl} from '@angular/forms'; import {UntypedFormControl} from '@angular/forms';
import {debounceTime, distinctUntilChanged, filter, map} from 'rxjs/operators'; import {debounceTime, distinctUntilChanged, filter, map} from 'rxjs/operators';
import {fade} from '../../../animations'; import {fade} from '../../../animations';
import {delay} from '../../../services/delay';
import {TextRenderingService} from '../../songs/services/text-rendering.service'; import {TextRenderingService} from '../../songs/services/text-rendering.service';
import {Section} from '../../songs/services/section'; import {Section} from '../../songs/services/section';
import {GlobalSettings} from '../../../services/global-settings'; import {GlobalSettings} from '../../../services/global-settings';
@@ -27,6 +26,7 @@ export interface PresentationSong {
templateUrl: './remote.component.html', templateUrl: './remote.component.html',
styleUrls: ['./remote.component.less'], styleUrls: ['./remote.component.less'],
animations: [fade], animations: [fade],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class RemoteComponent { export class RemoteComponent {
public shows$: Observable<Show[]>; public shows$: Observable<Show[]>;
@@ -71,22 +71,21 @@ export class RemoteComponent {
} }
public async onShowChanged(change: string, updateShow = true): Promise<void> { public async onShowChanged(change: string, updateShow = true): Promise<void> {
this.progress = true;
if (updateShow) { if (updateShow) {
await this.showService.update$(change, {presentationSongId: 'empty'});
await delay(200);
await this.globalSettingsService.set({currentShow: change}); await this.globalSettingsService.set({currentShow: change});
await this.showService.update$(change, {presentationSongId: 'title'}); await this.showService.update$(change, {presentationSongId: 'title'});
} }
this.currentShowId = change; this.currentShowId = change;
this.showService this.showService
.read$(change) .read$(change)
.pipe(debounceTime(100)) .pipe(debounceTime(10))
.subscribe(show => { .subscribe(show => {
this.show = show; this.show = show;
}); });
combineLatest([this.showService.read$(change), this.showSongService.list$(change)]).subscribe(([show, list]) => { combineLatest([this.showService.read$(change), this.showSongService.list$(change)])
.pipe(debounceTime(10))
.subscribe(([show, list]) => {
this.showSongs = list; this.showSongs = list;
const presentationSongs = list.map(song => ({ const presentationSongs = list.map(song => ({
id: song.id, id: song.id,
@@ -95,8 +94,6 @@ export class RemoteComponent {
})); }));
this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? []; this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? [];
}); });
await delay(500);
this.progress = false;
} }
public getFirstLine(section: Section): string { public getFirstLine(section: Section): string {