Merge pull request #2414 from mononaut/fix-ln-map-unfurls

Fix unfurls for lightning pages with no geodata
This commit is contained in:
wiz 2022-08-28 14:31:12 +02:00 committed by GitHub
commit a83b2ddeea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -58,7 +58,7 @@
</table>
</div>
<div class="col-md map-col">
<app-nodes-channels-map *ngIf="!error" [style]="'channelpage'" [channel]="channelGeo" [fitContainer]="true" (readyEvent)="onMapReady()"></app-nodes-channels-map>
<app-nodes-channels-map *ngIf="!error" [style]="'channelpage'" [channel]="channelGeo" [fitContainer]="true" [placeholder]="true" (readyEvent)="onMapReady()"></app-nodes-channels-map>
</div>
</div>
</div>

View File

@ -52,7 +52,7 @@
</table>
</div>
<div class="col-md map-col">
<app-nodes-channels-map *ngIf="!error" [style]="'nodepage'" [publicKey]="node.public_key" [fitContainer]="true" (readyEvent)="onMapReady()"></app-nodes-channels-map>
<app-nodes-channels-map *ngIf="!error" [style]="'nodepage'" [publicKey]="node.public_key" [fitContainer]="true" [placeholder]="true" [hasLocation]="!!node.as_number" (readyEvent)="onMapReady()"></app-nodes-channels-map>
</div>
</div>
</div>

View File

@ -22,6 +22,7 @@ export class NodesChannelsMap implements OnInit {
@Input() channel: any[] = [];
@Input() fitContainer = false;
@Input() hasLocation = true;
@Input() placeholder = false;
@Output() readyEvent = new EventEmitter();
channelsObservable: Observable<any>;
@ -201,11 +202,26 @@ export class NodesChannelsMap implements OnInit {
prepareChartOptions(nodes, channels) {
let title: object;
if (channels.length === 0) {
if (channels.length === 0 && !this.placeholder) {
this.chartOptions = null;
return;
}
// empty map fallback
if (channels.length === 0 && this.placeholder) {
title = {
textStyle: {
color: 'white',
fontSize: 18
},
text: $localize`No geolocation data available`,
left: 'center',
top: 'center'
};
this.zoom = 1.5;
this.center = [0, 20];
}
this.chartOptions = {
silent: this.style === 'widget',
title: title ?? undefined,