RED-3800: quick fix for last visited page

This commit is contained in:
Dan Percic 2022-06-28 20:07:58 +03:00
parent 7ed1c2dbbd
commit d6fec8cac9

View File

@ -6,7 +6,6 @@ import {
bool, bool,
CircleButtonTypes, CircleButtonTypes,
CustomError, CustomError,
Debounce,
ErrorService, ErrorService,
FilterService, FilterService,
List, List,
@ -306,14 +305,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
} }
} }
viewerPageChanged(page: number) {
// this.multiSelectService.deactivate();
return this.#updateQueryParamsPage(page);
}
@Debounce(100)
async viewerReady() { async viewerReady() {
// Go to initial page from query params
const pageNumber: string = this._activatedRoute.snapshot.queryParams.page; const pageNumber: string = this._activatedRoute.snapshot.queryParams.page;
if (pageNumber) { if (pageNumber) {
const file = this.state.file; const file = this.state.file;
@ -326,7 +318,9 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
page = file.numberOfPages; page = file.numberOfPages;
} }
this.pdf.navigateTo(page); setTimeout(() => {
this.pdf.navigateTo(page);
}, 300);
} }
this._loadingService.stop(); this._loadingService.stop();
@ -450,6 +444,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
} }
async #updateQueryParamsPage(page: number): Promise<void> { async #updateQueryParamsPage(page: number): Promise<void> {
console.log('updateQueryParamsPage: ', page);
const extras: NavigationExtras = { const extras: NavigationExtras = {
queryParams: { page }, queryParams: { page },
queryParamsHandling: 'merge', queryParamsHandling: 'merge',
@ -557,7 +552,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
}); });
this.addActiveScreenSubscription = this.pdfProxyService.pageChanged$.subscribe(page => this.addActiveScreenSubscription = this.pdfProxyService.pageChanged$.subscribe(page =>
this._ngZone.run(() => this.viewerPageChanged(page)), this._ngZone.run(() => {
console.log('viewerPageChanged', page);
return this.#updateQueryParamsPage(page);
}),
); );
this.addActiveScreenSubscription = this.pdfProxyService.annotationSelected$.subscribe(); this.addActiveScreenSubscription = this.pdfProxyService.annotationSelected$.subscribe();
} }