Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(geo): check catalog not undefined before loading items #1583

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
IgoMap
} from '@igo2/geo';

import { BehaviorSubject, Subscription } from 'rxjs';
import { BehaviorSubject, Subscription, combineLatest } from 'rxjs';
import { take } from 'rxjs/operators';

import { MapState } from '../../map/map.state';
Expand Down Expand Up @@ -52,11 +52,6 @@ export class CatalogBrowserToolComponent implements OnInit, OnDestroy {
*/
private catalog$$: Subscription;

/**
* Subscription for authentication
*/
private authenticate$$: Subscription;

/**
* Whether a group can be toggled when it's collapsed
*/
Expand All @@ -82,28 +77,25 @@ export class CatalogBrowserToolComponent implements OnInit, OnDestroy {
*/
ngOnInit() {
const catalogStore = this.catalogState.catalogStore;
this.catalog$$ = catalogStore.stateView
.firstBy$(
(record: EntityRecord<Catalog>) => record.state.selected === true
)
.subscribe((record: EntityRecord<Catalog>) => {
if (record && record.entity) {
const catalog = record.entity;
this.catalog = catalog;
}
});

this.authenticate$$ = this.authService.authenticate$.subscribe(() => {
this.loadCatalogItems(this.catalog);
});
const catalog$ = catalogStore.stateView.firstBy$(
(record: EntityRecord<Catalog>) => record.state.selected === true
);
const authenticate$ = this.authService.authenticate$;
this.catalog$$ = combineLatest([catalog$, authenticate$]).subscribe(
([record, authenticate]) => {
const catalog = record.entity;
this.catalog = catalog;
this.loadCatalogItems(this.catalog);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On ne semble pas régler le problème mais plutot éviter de la renvoyer. Rapidement ça me semble être un problème de concurence entre les deux observables. Il faudrait trouver un moyen de corriger ce problème

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui exactement, problème de concurrence, parfois this.catalog est undefined.

);
}

/**
* @internal
*/
ngOnDestroy() {
this.catalog$$.unsubscribe();
this.authenticate$$.unsubscribe();
}

/**
Expand Down