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);
}
}

View File

@@ -42,9 +42,9 @@ export class NodePreviewComponent implements OnInit {
this.node$ = this.activatedRoute.paramMap
.pipe(
switchMap((params: ParamMap) => {
this.openGraphService.waitFor('node-map');
this.openGraphService.waitFor('node-data');
this.publicKey = params.get('public_key');
this.publicKey = params.get('public_key');
this.openGraphService.waitFor('node-map-' + this.publicKey);
this.openGraphService.waitFor('node-data-' + this.publicKey);
return this.lightningApiService.getNode$(params.get('public_key'));
}),
map((node) => {
@@ -75,14 +75,14 @@ export class NodePreviewComponent implements OnInit {
this.socketTypes = Object.keys(socketTypesMap);
node.avgCapacity = node.capacity / Math.max(1, node.active_channel_count);
this.openGraphService.waitOver('node-data');
this.openGraphService.waitOver('node-data-' + this.publicKey);
return node;
}),
catchError(err => {
this.error = err;
this.openGraphService.fail('node-map');
this.openGraphService.fail('node-data');
this.openGraphService.fail('node-map-' + this.publicKey);
this.openGraphService.fail('node-data-' + this.publicKey);
return [{
alias: this.publicKey,
public_key: this.publicKey,
@@ -100,6 +100,6 @@ export class NodePreviewComponent implements OnInit {
}
onMapReady() {
this.openGraphService.waitOver('node-map');
this.openGraphService.waitOver('node-map-' + this.publicKey);
}
}