optimize remote load
This commit is contained in:
@@ -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(_ => !!_),
|
||||||
|
|||||||
@@ -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,32 +71,29 @@ 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)])
|
||||||
this.showSongs = list;
|
.pipe(debounceTime(10))
|
||||||
const presentationSongs = list.map(song => ({
|
.subscribe(([show, list]) => {
|
||||||
id: song.id,
|
this.showSongs = list;
|
||||||
title: song.title,
|
const presentationSongs = list.map(song => ({
|
||||||
sections: this.textRenderingService.parse(song.text, null),
|
id: song.id,
|
||||||
}));
|
title: song.title,
|
||||||
this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? [];
|
sections: this.textRenderingService.parse(song.text, null),
|
||||||
});
|
}));
|
||||||
await delay(500);
|
this.presentationSongs = show?.order.map(_ => presentationSongs.filter(f => f.id === _)[0]) ?? [];
|
||||||
this.progress = false;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFirstLine(section: Section): string {
|
public getFirstLine(section: Section): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user