From d7a7095b8d884b8e3a3651b366f735630ec0c89e Mon Sep 17 00:00:00 2001 From: softsimon Date: Sat, 4 Apr 2020 21:47:05 +0700 Subject: [PATCH] Prepend network name to title when on testnet or liquid. --- .../app/components/address/address.component.ts | 2 +- .../src/app/components/block/block.component.ts | 2 +- .../transaction/transaction.component.ts | 2 +- frontend/src/app/services/seo.service.ts | 17 ++++++++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/components/address/address.component.ts b/frontend/src/app/components/address/address.component.ts index e6d8c51a7..5ec5536f4 100644 --- a/frontend/src/app/components/address/address.component.ts +++ b/frontend/src/app/components/address/address.component.ts @@ -60,7 +60,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); + this.seoService.setTitle('Address: ' + this.addressString, true); 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 101103d99..c44cc7c11 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -59,7 +59,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); + this.seoService.setTitle('Block: #' + block.height + ': ' + block.id, true); this.isLoadingBlock = false; this.setBlockSubsidy(); if (block.reward) { diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 63ad02a76..c510b9190 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -45,7 +45,7 @@ export class TransactionComponent implements OnInit, OnDestroy { this.route.paramMap.pipe( switchMap((params: ParamMap) => { this.txId = params.get('id') || ''; - this.seoService.setTitle('Transaction: ' + this.txId); + this.seoService.setTitle('Transaction: ' + this.txId, true); this.error = undefined; this.feeRating = undefined; this.isLoadingTx = true; diff --git a/frontend/src/app/services/seo.service.ts b/frontend/src/app/services/seo.service.ts index 9c919a1ad..574f70af4 100644 --- a/frontend/src/app/services/seo.service.ts +++ b/frontend/src/app/services/seo.service.ts @@ -1,18 +1,29 @@ import { Injectable } from '@angular/core'; -import { Title, Meta } from '@angular/platform-browser'; +import { Title } from '@angular/platform-browser'; +import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' }) export class SeoService { + network = environment.network; defaultTitle = 'mempool - Bitcoin Explorer'; constructor( private titleService: Title, ) { } - setTitle(newTitle: string) { - this.titleService.setTitle(newTitle + ' - ' + this.defaultTitle); + setTitle(newTitle: string, prependNetwork = false) { + let networkName = ''; + if (prependNetwork) { + if (this.network === 'liquid') { + networkName = 'Liquid '; + } else if (this.network === 'testnet') { + networkName = 'Testnet '; + } + } + + this.titleService.setTitle(networkName + newTitle + ' - ' + this.defaultTitle); } resetTitle() {