ActivityPub-federated video streaming platform using P2P directly in your web browser
Add about endpoint cache
Chocobozzza22e1950d7ba
diff --git a/client/src/app/+about/about-instance/about-instance.resolver.ts b/client/src/app/+about/about-instance/about-instance.resolver.tsindex cb96b2f761..d462aa9dfb 100644--- a/client/src/app/+about/about-instance/about-instance.resolver.ts+++ b/client/src/app/+about/about-instance/about-instance.resolver.ts@@ -47,7 +47,7 @@ export class AboutInstanceResolver {}private buildInstanceAboutObservable () {- return this.instanceService.getAbout()+ return this.instanceService.getAboutWithCache().pipe(switchMap(about => {return forkJoin([diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.tsindex 9671a99e7a..1f2fbc1069 100644--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts@@ -250,7 +250,7 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {private buildLanguages () {forkJoin([- this.instanceService.getAbout(),+ this.instanceService.getAboutWithCache(),this.serverService.getVideoLanguages()]).pipe(map(([ about, languages ]) => ({ about, languages }))).subscribe(({ about, languages }) => {diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.tsindex 9b702bd467..185fc6e6ad 100644--- a/client/src/app/app.component.ts+++ b/client/src/app/app.component.ts@@ -351,7 +351,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {forkJoin([this.serverService.getConfig().pipe(first()),- this.instanceService.getAbout().pipe(first())+ this.instanceService.getAboutWithCache().pipe(first())]).subscribe(([ config, about ]) => {const instanceConfigWarningModalValue = this.instanceConfigWarningModal()if (instanceConfigWarningModalValue.shouldAutoOpen(config, about)) {diff --git a/client/src/app/shared/shared-instance/instance-about-accordion.component.ts b/client/src/app/shared/shared-instance/instance-about-accordion.component.tsindex 033499be93..1c3aae2fed 100644--- a/client/src/app/shared/shared-instance/instance-about-accordion.component.ts+++ b/client/src/app/shared/shared-instance/instance-about-accordion.component.ts@@ -66,7 +66,7 @@ export class InstanceAboutAccordionComponent implements OnInit {pluginPanels: { id: string, title: string, html: string }[] = []async ngOnInit () {- this.instanceService.getAbout()+ this.instanceService.getAboutWithCache().subscribe({next: async about => {this.about = aboutdiff --git a/client/src/app/shared/shared-main/instance/instance.service.ts b/client/src/app/shared/shared-main/instance/instance.service.tsindex d46a57178c..865612c844 100644--- a/client/src/app/shared/shared-main/instance/instance.service.ts+++ b/client/src/app/shared/shared-main/instance/instance.service.ts@@ -4,8 +4,8 @@ import { MarkdownService, RestExtractor, ServerService } from '@app/core'import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils'import { About } from '@peertube/peertube-models'import { logger } from '@root-helpers/logger'-import { forkJoin } from 'rxjs'-import { catchError, map } from 'rxjs/operators'+import { forkJoin, Observable } from 'rxjs'+import { catchError, map, shareReplay } from 'rxjs/operators'import { environment } from '../../../../environments/environment'export type AboutHTML = Pick<@@ -30,9 +30,22 @@ export class InstanceService {static BASE_CONFIG_URL = environment.apiUrl + '/api/v1/config'static BASE_SERVER_URL = environment.apiUrl + '/api/v1/server'- getAbout () {- return this.authHttp.get<About>(InstanceService.BASE_CONFIG_URL + '/about')- .pipe(catchError(res => this.restExtractor.handleError(res)))+ private aboutCache$: Observable<About> | null = null++ getAboutWithCache () {+ if (!this.aboutCache$) {+ this.aboutCache$ = this.authHttp.get<About>(InstanceService.BASE_CONFIG_URL + '/about')+ .pipe(+ catchError(res => this.restExtractor.handleError(res)),+ shareReplay(1)+ )++ setTimeout(() => {+ this.aboutCache$ = null+ }, 1000)+ }++ return this.aboutCache$}// ---------------------------------------------------------------------------