Better fix for unfurler race condition

This commit is contained in:
Mononaut
2022-08-31 17:24:56 +00:00
parent 5300f84e77
commit 8bd4fcdab6
8 changed files with 56 additions and 46 deletions

View File

@@ -16,6 +16,7 @@ export class ChannelPreviewComponent implements OnInit {
channel$: Observable<any>;
error: any = null;
channelGeo: number[] = [];
shortId: string;
constructor(
private lightningApiService: LightningApiService,
@@ -28,8 +29,9 @@ export class ChannelPreviewComponent implements OnInit {
this.channel$ = this.activatedRoute.paramMap
.pipe(
switchMap((params: ParamMap) => {
this.openGraphService.waitFor('channel-map');
this.openGraphService.waitFor('channel-data');
this.shortId = params.get('short_id') || '';
this.openGraphService.waitFor('channel-map-' + this.shortId);
this.openGraphService.waitFor('channel-data-' + this.shortId);
this.error = null;
this.seoService.setTitle(`Channel: ${params.get('short_id')}`);
return this.lightningApiService.getChannel$(params.get('short_id'))
@@ -48,12 +50,12 @@ export class ChannelPreviewComponent implements OnInit {
data.node_right.longitude, data.node_right.latitude,
];
}
this.openGraphService.waitOver('channel-data');
this.openGraphService.waitOver('channel-data-' + this.shortId);
}),
catchError((err) => {
this.error = err;
this.openGraphService.fail('channel-map');
this.openGraphService.fail('channel-data');
this.openGraphService.fail('channel-map-' + this.shortId);
this.openGraphService.fail('channel-data-' + this.shortId);
return of(null);
})
);
@@ -62,6 +64,6 @@ export class ChannelPreviewComponent implements OnInit {
}
onMapReady() {
this.openGraphService.waitOver('channel-map');
this.openGraphService.waitOver('channel-map-' + this.shortId);
}
}