1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-07-07 00:57:28 +02:00

improve race condition for opening lightbox

This commit is contained in:
Patrik J. Braun
2023-09-20 22:03:25 +02:00
parent 1bf1306237
commit f4cdb5a83a
3 changed files with 250 additions and 245 deletions

View File

@ -2,7 +2,7 @@ import {Injectable} from '@angular/core';
import {BehaviorSubject, Observable} from 'rxjs'; import {BehaviorSubject, Observable} from 'rxjs';
import {PhotoDTO} from '../../../../../common/entities/PhotoDTO'; import {PhotoDTO} from '../../../../../common/entities/PhotoDTO';
import {DirectoryContent} from '../contentLoader.service'; import {DirectoryContent} from '../contentLoader.service';
import {map, switchMap} from 'rxjs/operators'; import {debounceTime, map, switchMap} from 'rxjs/operators';
export enum FilterRenderType { export enum FilterRenderType {
enum = 1, enum = 1,
@ -224,6 +224,7 @@ export class FilterService {
directoryContent: Observable<DirectoryContent> directoryContent: Observable<DirectoryContent>
): Observable<DirectoryContent> { ): Observable<DirectoryContent> {
return directoryContent.pipe( return directoryContent.pipe(
debounceTime(1),
switchMap((dirContent: DirectoryContent) => { switchMap((dirContent: DirectoryContent) => {
this.statistic = this.getStatistic(dirContent); this.statistic = this.getStatistic(dirContent);
this.resetFilters(false); this.resetFilters(false);

View File

@ -385,6 +385,9 @@ export class GalleryGridComponent
* Makes sure that the photo with the given mediaString is visible on the screen * Makes sure that the photo with the given mediaString is visible on the screen
*/ */
private renderUpToMedia(mediaStringId: string): void { private renderUpToMedia(mediaStringId: string): void {
if (!this.mediaGroups) {
return;
}
let groupIndex = -1; let groupIndex = -1;
let mediaIndex = -1; let mediaIndex = -1;
for (let i = 0; i < this.mediaGroups.length; ++i) { for (let i = 0; i < this.mediaGroups.length; ++i) {

View File

@ -105,11 +105,12 @@ export class GalleryLightboxComponent implements OnDestroy, OnInit {
this.updatePhotoFrameDim(); this.updatePhotoFrameDim();
this.subscription.route = this.route.queryParams.subscribe( this.subscription.route = this.route.queryParams.subscribe(
(params: Params) => { (params: Params) => {
this.delayedMediaShow = null;
if ( if (
params[QueryParams.gallery.photo] && params[QueryParams.gallery.photo] &&
params[QueryParams.gallery.photo] !== '' params[QueryParams.gallery.photo] !== ''
) { ) {
this.delayedMediaShow = params[QueryParams.gallery.photo] this.delayedMediaShow = params[QueryParams.gallery.photo];
// photos are not yet available to show // photos are not yet available to show
if (!this.gridPhotoQL) { if (!this.gridPhotoQL) {
return; return;