diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-08 15:59:05 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-08 15:59:05 +0200 |
commit | b51e5b74019bcd67d9adafd48c0cd79affe84892 (patch) | |
tree | e1d1a4d4cdbcdc268fe0b7e955f2e6c31d0d58d9 /client/src | |
parent | efa3fef23ecf4e1c5289f8715de184c272ea49f7 (diff) | |
download | PeerTube-b51e5b74019bcd67d9adafd48c0cd79affe84892.tar.gz PeerTube-b51e5b74019bcd67d9adafd48c0cd79affe84892.tar.zst PeerTube-b51e5b74019bcd67d9adafd48c0cd79affe84892.zip |
Correctly disable infinite scroll for reuse
Diffstat (limited to 'client/src')
4 files changed, 13 insertions, 8 deletions
diff --git a/client/src/app/core/routing/custom-reuse-strategy.ts b/client/src/app/core/routing/custom-reuse-strategy.ts index 3000093a8..1498e221f 100644 --- a/client/src/app/core/routing/custom-reuse-strategy.ts +++ b/client/src/app/core/routing/custom-reuse-strategy.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { ComponentRef, Injectable } from '@angular/core' |
2 | import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' | 2 | import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' |
3 | import { RouterSetting } from './' | 3 | import { DisableForReuseHook } from './disable-for-reuse-hook' |
4 | import { PeerTubeRouterService } from './peertube-router.service' | 4 | import { PeerTubeRouterService, RouterSetting } from './peertube-router.service' |
5 | 5 | ||
6 | @Injectable() | 6 | @Injectable() |
7 | export class CustomReuseStrategy implements RouteReuseStrategy { | 7 | export class CustomReuseStrategy implements RouteReuseStrategy { |
@@ -22,9 +22,11 @@ export class CustomReuseStrategy implements RouteReuseStrategy { | |||
22 | const key = this.generateKey(route) | 22 | const key = this.generateKey(route) |
23 | this.recentlyUsed = key | 23 | this.recentlyUsed = key |
24 | 24 | ||
25 | console.log('Storing component %s to reuse later.', key); | 25 | console.log('Storing component %s to reuse later.', key) |
26 | 26 | ||
27 | (handle as any).componentRef.instance.disableForReuse() | 27 | const componentRef = (handle as any).componentRef as ComponentRef<DisableForReuseHook> |
28 | componentRef.instance.disableForReuse() | ||
29 | componentRef.changeDetectorRef.detectChanges() | ||
28 | 30 | ||
29 | this.storedRouteHandles.set(key, handle) | 31 | this.storedRouteHandles.set(key, handle) |
30 | 32 | ||
diff --git a/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts b/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts index bebc6efa7..c247cfde2 100644 --- a/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts +++ b/client/src/app/shared/shared-main/angular/infinite-scroller.directive.ts | |||
@@ -13,6 +13,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy, AfterViewCh | |||
13 | 13 | ||
14 | // Add angular state in query params to reuse the routed component | 14 | // Add angular state in query params to reuse the routed component |
15 | @Input() setAngularState: boolean | 15 | @Input() setAngularState: boolean |
16 | @Input() parentDisabled = false | ||
16 | 17 | ||
17 | @Output() nearOfBottom = new EventEmitter<void>() | 18 | @Output() nearOfBottom = new EventEmitter<void>() |
18 | 19 | ||
@@ -74,7 +75,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy, AfterViewCh | |||
74 | filter(({ current, maximumScroll }) => (current / maximumScroll) > this.decimalLimit) | 75 | filter(({ current, maximumScroll }) => (current / maximumScroll) > this.decimalLimit) |
75 | ) | 76 | ) |
76 | .subscribe(() => { | 77 | .subscribe(() => { |
77 | if (this.setAngularState) this.setScrollRouteParams() | 78 | if (this.setAngularState && !this.parentDisabled) this.setScrollRouteParams() |
78 | 79 | ||
79 | this.nearOfBottom.emit() | 80 | this.nearOfBottom.emit() |
80 | }) | 81 | }) |
diff --git a/client/src/app/shared/shared-video-miniature/videos-list.component.html b/client/src/app/shared/shared-video-miniature/videos-list.component.html index 67933f177..2b554517f 100644 --- a/client/src/app/shared/shared-video-miniature/videos-list.component.html +++ b/client/src/app/shared/shared-video-miniature/videos-list.component.html | |||
@@ -40,7 +40,8 @@ | |||
40 | 40 | ||
41 | <div class="no-results" i18n *ngIf="hasDoneFirstQuery && videos.length === 0">No results.</div> | 41 | <div class="no-results" i18n *ngIf="hasDoneFirstQuery && videos.length === 0">No results.</div> |
42 | <div | 42 | <div |
43 | myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [dataObservable]="onDataSubject.asObservable()" [setAngularState]="true" | 43 | myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [dataObservable]="onDataSubject.asObservable()" |
44 | [setAngularState]="true" [parentDisabled]="disabled" | ||
44 | class="videos" [ngClass]="{ 'display-as-row': displayAsRow }" | 45 | class="videos" [ngClass]="{ 'display-as-row': displayAsRow }" |
45 | > | 46 | > |
46 | <ng-container *ngFor="let video of videos; trackBy: videoById;"> | 47 | <ng-container *ngFor="let video of videos; trackBy: videoById;"> |
diff --git a/client/src/app/shared/shared-video-miniature/videos-selection.component.html b/client/src/app/shared/shared-video-miniature/videos-selection.component.html index f2af874dd..6ea2661e4 100644 --- a/client/src/app/shared/shared-video-miniature/videos-selection.component.html +++ b/client/src/app/shared/shared-video-miniature/videos-selection.component.html | |||
@@ -2,7 +2,8 @@ | |||
2 | 2 | ||
3 | <div | 3 | <div |
4 | class="videos" | 4 | class="videos" |
5 | myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [dataObservable]="onDataSubject.asObservable()" [setAngularState]="true" | 5 | myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [dataObservable]="onDataSubject.asObservable()" |
6 | [parentDisabled]="disabled" [setAngularState]="true" | ||
6 | > | 7 | > |
7 | <div class="video" *ngFor="let video of videos; let i = index; trackBy: videoById"> | 8 | <div class="video" *ngFor="let video of videos; let i = index; trackBy: videoById"> |
8 | 9 | ||