Handle missing blocks/addresses in preview
This commit is contained in:
parent
31ced9e23c
commit
bbf04648f9
@ -73,6 +73,7 @@ export class AddressPreviewComponent implements OnInit, OnDestroy {
|
|||||||
this.isLoadingAddress = false;
|
this.isLoadingAddress = false;
|
||||||
this.error = err;
|
this.error = err;
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
this.openGraphService.waitOver('address-data');
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -98,6 +99,7 @@ export class AddressPreviewComponent implements OnInit, OnDestroy {
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.isLoadingAddress = false;
|
this.isLoadingAddress = false;
|
||||||
|
this.openGraphService.waitOver('address-data');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
|
||||||
import { ActivatedRoute, ParamMap } from '@angular/router';
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
||||||
import { ElectrsApiService } from '../../services/electrs-api.service';
|
import { ElectrsApiService } from '../../services/electrs-api.service';
|
||||||
import { switchMap, tap, throttleTime, catchError, shareReplay, startWith, pairwise } from 'rxjs/operators';
|
import { switchMap, tap, throttleTime, catchError, shareReplay, startWith, pairwise, filter } from 'rxjs/operators';
|
||||||
import { of, Subscription, asyncScheduler } from 'rxjs';
|
import { of, Subscription, asyncScheduler } from 'rxjs';
|
||||||
import { StateService } from '../../services/state.service';
|
import { StateService } from '../../services/state.service';
|
||||||
import { SeoService } from 'src/app/services/seo.service';
|
import { SeoService } from 'src/app/services/seo.service';
|
||||||
@ -54,6 +54,7 @@ export class BlockPreviewComponent implements OnInit, OnDestroy {
|
|||||||
const blockHash: string = params.get('id') || '';
|
const blockHash: string = params.get('id') || '';
|
||||||
this.block = undefined;
|
this.block = undefined;
|
||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
|
this.overviewError = undefined;
|
||||||
this.fees = undefined;
|
this.fees = undefined;
|
||||||
|
|
||||||
let isBlockHeight = false;
|
let isBlockHeight = false;
|
||||||
@ -70,13 +71,24 @@ export class BlockPreviewComponent implements OnInit, OnDestroy {
|
|||||||
return this.electrsApiService.getBlockHashFromHeight$(parseInt(blockHash, 10))
|
return this.electrsApiService.getBlockHashFromHeight$(parseInt(blockHash, 10))
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((hash) => {
|
switchMap((hash) => {
|
||||||
|
if (hash) {
|
||||||
this.blockHash = hash;
|
this.blockHash = hash;
|
||||||
return this.apiService.getBlock$(hash);
|
return this.apiService.getBlock$(hash);
|
||||||
})
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
catchError((err) => {
|
||||||
|
this.error = err;
|
||||||
|
this.openGraphService.waitOver('block-data');
|
||||||
|
this.openGraphService.waitOver('block-viz');
|
||||||
|
return of(null);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this.apiService.getBlock$(blockHash);
|
return this.apiService.getBlock$(blockHash);
|
||||||
}),
|
}),
|
||||||
|
filter((block: BlockExtended | void) => block != null),
|
||||||
tap((block: BlockExtended) => {
|
tap((block: BlockExtended) => {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.blockHeight = block.height;
|
this.blockHeight = block.height;
|
||||||
@ -104,6 +116,7 @@ export class BlockPreviewComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(
|
.pipe(
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.overviewError = err;
|
this.overviewError = err;
|
||||||
|
this.openGraphService.waitOver('block-viz');
|
||||||
return of([]);
|
return of([]);
|
||||||
}),
|
}),
|
||||||
switchMap((transactions) => {
|
switchMap((transactions) => {
|
||||||
@ -123,6 +136,8 @@ export class BlockPreviewComponent implements OnInit, OnDestroy {
|
|||||||
(error) => {
|
(error) => {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.isLoadingOverview = false;
|
this.isLoadingOverview = false;
|
||||||
|
this.openGraphService.waitOver('block-viz');
|
||||||
|
this.openGraphService.waitOver('block-data');
|
||||||
if (this.blockGraph) {
|
if (this.blockGraph) {
|
||||||
this.blockGraph.destroy();
|
this.blockGraph.destroy();
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,10 @@ export class OpenGraphService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// expose this service to global scope, so we can access it from the unfurler
|
// expose routing method to global scope, so we can access it from the unfurler
|
||||||
window['ogService'] = this;
|
window['ogService'] = {
|
||||||
|
loadPage: (path) => { return this.loadPage(path) }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setOgImage() {
|
setOgImage() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mempool-unfurl",
|
"name": "mempool-unfurl",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "Renderer for mempool open graph link preview images",
|
"description": "Renderer for mempool open graph link preview images",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -193,11 +193,11 @@ class Server {
|
|||||||
getDefaultImageUrl() {
|
getDefaultImageUrl() {
|
||||||
switch (this.network) {
|
switch (this.network) {
|
||||||
case 'liquid':
|
case 'liquid':
|
||||||
return '/resources/liquid/liquid-network-preview.png';
|
return this.mempoolHost + '/resources/liquid/liquid-network-preview.png';
|
||||||
case 'bisq':
|
case 'bisq':
|
||||||
return '/resources/bisq/bisq-markets-preview.png';
|
return this.mempoolHost + '/resources/bisq/bisq-markets-preview.png';
|
||||||
default:
|
default:
|
||||||
return '/resources/mempool-space-preview.png';
|
return this.mempoolHost + '/resources/mempool-space-preview.png';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user