diff --git a/frontend/src/app/bisq/bisq-address/bisq-address.component.ts b/frontend/src/app/bisq/bisq-address/bisq-address.component.ts index a82a31e58..f3968fcf0 100644 --- a/frontend/src/app/bisq/bisq-address/bisq-address.component.ts +++ b/frontend/src/app/bisq/bisq-address/bisq-address.component.ts @@ -36,7 +36,7 @@ export class BisqAddressComponent implements OnInit, OnDestroy { this.transactions = null; document.body.scrollTo(0, 0); this.addressString = params.get('id') || ''; - this.seoService.setTitle('Address: ' + this.addressString, true); + this.seoService.setTitle('Address: ' + this.addressString); return this.bisqApiService.getAddress$(this.addressString) .pipe( diff --git a/frontend/src/app/bisq/bisq-block/bisq-block.component.ts b/frontend/src/app/bisq/bisq-block/bisq-block.component.ts index 9ce3be8fb..6980f3ae8 100644 --- a/frontend/src/app/bisq/bisq-block/bisq-block.component.ts +++ b/frontend/src/app/bisq/bisq-block/bisq-block.component.ts @@ -82,7 +82,7 @@ export class BisqBlockComponent implements OnInit, OnDestroy { } this.isLoading = false; this.blockHeight = block.height; - this.seoService.setTitle('Block: #' + block.height + ': ' + block.hash, true); + this.seoService.setTitle('Block: #' + block.height + ': ' + block.hash); this.block = block; }); } diff --git a/frontend/src/app/bisq/bisq-blocks/bisq-blocks.component.ts b/frontend/src/app/bisq/bisq-blocks/bisq-blocks.component.ts index 76845a0fc..0b16ad471 100644 --- a/frontend/src/app/bisq/bisq-blocks/bisq-blocks.component.ts +++ b/frontend/src/app/bisq/bisq-blocks/bisq-blocks.component.ts @@ -33,7 +33,7 @@ export class BisqBlocksComponent implements OnInit { ) { } ngOnInit(): void { - this.seoService.setTitle('Blocks', true); + this.seoService.setTitle('Blocks'); this.itemsPerPage = Math.max(Math.round(this.contentSpace / this.fiveItemsPxSize) * 5, 10); this.loadingItems = Array(this.itemsPerPage); if (document.body.clientWidth < 768) { diff --git a/frontend/src/app/bisq/bisq-stats/bisq-stats.component.ts b/frontend/src/app/bisq/bisq-stats/bisq-stats.component.ts index 787cad58c..9b58e621e 100644 --- a/frontend/src/app/bisq/bisq-stats/bisq-stats.component.ts +++ b/frontend/src/app/bisq/bisq-stats/bisq-stats.component.ts @@ -21,7 +21,7 @@ export class BisqStatsComponent implements OnInit { ) { } ngOnInit() { - this.seoService.setTitle('BSQ Statistics', false); + this.seoService.setTitle('BSQ Statistics'); this.stateService.bsqPrice$ .subscribe((bsqPrice) => { diff --git a/frontend/src/app/bisq/bisq-transaction/bisq-transaction.component.ts b/frontend/src/app/bisq/bisq-transaction/bisq-transaction.component.ts index 6da3c369f..50b880113 100644 --- a/frontend/src/app/bisq/bisq-transaction/bisq-transaction.component.ts +++ b/frontend/src/app/bisq/bisq-transaction/bisq-transaction.component.ts @@ -43,7 +43,7 @@ export class BisqTransactionComponent implements OnInit, OnDestroy { this.error = null; document.body.scrollTo(0, 0); this.txId = params.get('id') || ''; - this.seoService.setTitle('Transaction: ' + this.txId, true); + this.seoService.setTitle('Transaction: ' + this.txId); if (history.state.data) { return of(history.state.data); } diff --git a/frontend/src/app/bisq/bisq-transactions/bisq-transactions.component.ts b/frontend/src/app/bisq/bisq-transactions/bisq-transactions.component.ts index 33f431275..b911d5910 100644 --- a/frontend/src/app/bisq/bisq-transactions/bisq-transactions.component.ts +++ b/frontend/src/app/bisq/bisq-transactions/bisq-transactions.component.ts @@ -72,7 +72,7 @@ export class BisqTransactionsComponent implements OnInit { ) { } ngOnInit(): void { - this.seoService.setTitle('Transactions', true); + this.seoService.setTitle('Transactions'); this.radioGroupForm = this.formBuilder.group({ txTypes: [this.txTypesDefaultChecked], diff --git a/frontend/src/app/components/address/address.component.ts b/frontend/src/app/components/address/address.component.ts index 197a4fadf..a152437aa 100644 --- a/frontend/src/app/components/address/address.component.ts +++ b/frontend/src/app/components/address/address.component.ts @@ -61,7 +61,7 @@ export class AddressComponent implements OnInit, OnDestroy { this.transactions = null; document.body.scrollTo(0, 0); this.addressString = params.get('id') || ''; - this.seoService.setTitle('Address: ' + this.addressString, true); + this.seoService.setTitle('Address: ' + this.addressString); return merge( of(true), diff --git a/frontend/src/app/components/asset/asset.component.ts b/frontend/src/app/components/asset/asset.component.ts index 4cd84540b..eea87a859 100644 --- a/frontend/src/app/components/asset/asset.component.ts +++ b/frontend/src/app/components/asset/asset.component.ts @@ -68,7 +68,7 @@ export class AssetComponent implements OnInit, OnDestroy { this.transactions = null; document.body.scrollTo(0, 0); this.assetString = params.get('id') || ''; - this.seoService.setTitle('Asset: ' + this.assetString, true); + this.seoService.setTitle('Asset: ' + this.assetString); return merge( of(true), diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index 6e0b25965..735e258c7 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -92,7 +92,7 @@ export class BlockComponent implements OnInit, OnDestroy { tap((block: Block) => { this.block = block; this.blockHeight = block.height; - this.seoService.setTitle('Block: #' + block.height + ': ' + block.id, true); + this.seoService.setTitle('Block: #' + block.height + ': ' + block.id); this.isLoadingBlock = false; if (block.coinbaseTx) { this.coinbaseTx = block.coinbaseTx; diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 1fe8ddf9b..1f5077339 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -44,7 +44,7 @@ export class TransactionComponent implements OnInit, OnDestroy { this.subscription = this.route.paramMap.pipe( switchMap((params: ParamMap) => { this.txId = params.get('id') || ''; - this.seoService.setTitle('Transaction: ' + this.txId, true); + this.seoService.setTitle('Transaction: ' + this.txId); this.resetTransaction(); return merge( of(true), diff --git a/frontend/src/app/services/seo.service.ts b/frontend/src/app/services/seo.service.ts index 455775d19..f53bb8a78 100644 --- a/frontend/src/app/services/seo.service.ts +++ b/frontend/src/app/services/seo.service.ts @@ -7,7 +7,6 @@ import { StateService } from './state.service'; }) export class SeoService { network = ''; - defaultTitle = 'mempool - Bitcoin Explorer'; constructor( private titleService: Title, @@ -16,15 +15,19 @@ export class SeoService { this.stateService.networkChanged$.subscribe((network) => this.network = network); } - setTitle(newTitle: string, prependNetwork = false) { - let networkName = ''; - if (prependNetwork && this.network !== '') { - networkName = this.network.substr(0, 1).toUpperCase() + this.network.substr(1) + ' '; - } - this.titleService.setTitle(networkName + newTitle + ' - ' + this.defaultTitle); + setTitle(newTitle: string): void { + this.titleService.setTitle(newTitle + ' - ' + this.getTitle()); } - resetTitle() { - this.titleService.setTitle(this.defaultTitle); + resetTitle(): void { + this.titleService.setTitle(this.getTitle()); + } + + getTitle(): string { + return 'mempool - ' + (this.network ? this.ucfirst(this.network) : 'Bitcoin') + ' Explorer'; + } + + ucfirst(str: string) { + return str.charAt(0).toUpperCase() + str.slice(1); } }