X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Frouting%2Fcustom-reuse-strategy.ts;h=1498e221fbf387533c4c9864b5be704045dca14e;hb=c55d76206cd462bad7eadd0c96f1ef5b3c629f9f;hp=a9f61acecb7d44bea4ef42dbe75c48fe96627b40;hpb=97567dd81f508dd6295ac4d73d849aa2ce0a6549;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/routing/custom-reuse-strategy.ts b/client/src/app/core/routing/custom-reuse-strategy.ts index a9f61acec..1498e221f 100644 --- a/client/src/app/core/routing/custom-reuse-strategy.ts +++ b/client/src/app/core/routing/custom-reuse-strategy.ts @@ -1,5 +1,9 @@ +import { ComponentRef, Injectable } from '@angular/core' import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' +import { DisableForReuseHook } from './disable-for-reuse-hook' +import { PeerTubeRouterService, RouterSetting } from './peertube-router.service' +@Injectable() export class CustomReuseStrategy implements RouteReuseStrategy { storedRouteHandles = new Map() recentlyUsed: string @@ -18,9 +22,11 @@ export class CustomReuseStrategy implements RouteReuseStrategy { const key = this.generateKey(route) this.recentlyUsed = key - console.log('Storing component %s to reuse later.', key); + console.log('Storing component %s to reuse later.', key) - (handle as any).componentRef.instance.disableForReuse() + const componentRef = (handle as any).componentRef as ComponentRef + componentRef.instance.disableForReuse() + componentRef.changeDetectorRef.detectChanges() this.storedRouteHandles.set(key, handle) @@ -76,6 +82,8 @@ export class CustomReuseStrategy implements RouteReuseStrategy { } private isReuseEnabled (route: ActivatedRouteSnapshot) { - return route.data.reuse && route.data.reuse.enabled && route.queryParams['a-state'] + // Cannot use peertube router here because of cyclic router dependency + return route.data.reuse?.enabled && + !!(route.queryParams[PeerTubeRouterService.ROUTE_SETTING_NAME] & RouterSetting.REUSE_COMPONENT) } }