Block navigation routing fix
This commit is contained in:
		
							parent
							
								
									a2b1669f94
								
							
						
					
					
						commit
						7309252bb8
					
				@ -8,10 +8,12 @@ import { Observable, of, Subscription } from 'rxjs';
 | 
			
		||||
import { StateService } from '../../services/state.service';
 | 
			
		||||
import { SeoService } from 'src/app/services/seo.service';
 | 
			
		||||
import { WebsocketService } from 'src/app/services/websocket.service';
 | 
			
		||||
import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-block',
 | 
			
		||||
  templateUrl: './block.component.html',
 | 
			
		||||
  providers: [RelativeUrlPipe],
 | 
			
		||||
  styleUrls: ['./block.component.scss']
 | 
			
		||||
})
 | 
			
		||||
export class BlockComponent implements OnInit, OnDestroy {
 | 
			
		||||
@ -51,6 +53,7 @@ export class BlockComponent implements OnInit, OnDestroy {
 | 
			
		||||
    private stateService: StateService,
 | 
			
		||||
    private seoService: SeoService,
 | 
			
		||||
    private websocketService: WebsocketService,
 | 
			
		||||
    private relativeUrlPipe: RelativeUrlPipe,
 | 
			
		||||
  ) { }
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
@ -194,7 +197,7 @@ export class BlockComponent implements OnInit, OnDestroy {
 | 
			
		||||
        if (this.showNextBlocklink) {
 | 
			
		||||
          this.navigateToNextBlock();
 | 
			
		||||
        } else {
 | 
			
		||||
          this.router.navigate([(this.network && this.stateService.env.BASE_MODULE === 'mempool' ? '/' + this.network : '') + '/mempool-block/', '0']);
 | 
			
		||||
          this.router.navigate([this.relativeUrlPipe.transform('/mempool-block'), '0']);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
@ -277,13 +280,13 @@ export class BlockComponent implements OnInit, OnDestroy {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    const block = this.latestBlocks.find((b) => b.height === this.nextBlockHeight - 2);
 | 
			
		||||
    this.router.navigate([(this.network && this.stateService.env.BASE_MODULE === 'mempool' ? '/' + this.network : '') + '/block/',
 | 
			
		||||
    this.router.navigate([this.relativeUrlPipe.transform('/block/'),
 | 
			
		||||
      block ? block.id : this.block.previousblockhash], { state: { data: { block, blockHeight: this.nextBlockHeight - 2 } } });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  navigateToNextBlock() {
 | 
			
		||||
    const block = this.latestBlocks.find((b) => b.height === this.nextBlockHeight);
 | 
			
		||||
    this.router.navigate([(this.network && this.stateService.env.BASE_MODULE === 'mempool' ? '/' + this.network : '') + '/block/',
 | 
			
		||||
    this.router.navigate([this.relativeUrlPipe.transform('/block/'),
 | 
			
		||||
      block ? block.id : this.nextBlockHeight], { state: { data: { block, blockHeight: this.nextBlockHeight } } });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -6,11 +6,13 @@ import { Router } from '@angular/router';
 | 
			
		||||
import { take, map, switchMap } from 'rxjs/operators';
 | 
			
		||||
import { feeLevels, mempoolFeeColors } from 'src/app/app.constants';
 | 
			
		||||
import { specialBlocks } from 'src/app/app.constants';
 | 
			
		||||
import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-mempool-blocks',
 | 
			
		||||
  templateUrl: './mempool-blocks.component.html',
 | 
			
		||||
  styleUrls: ['./mempool-blocks.component.scss'],
 | 
			
		||||
  providers: [RelativeUrlPipe],
 | 
			
		||||
  changeDetection: ChangeDetectionStrategy.OnPush,
 | 
			
		||||
})
 | 
			
		||||
export class MempoolBlocksComponent implements OnInit, OnDestroy {
 | 
			
		||||
@ -52,6 +54,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
 | 
			
		||||
    private router: Router,
 | 
			
		||||
    public stateService: StateService,
 | 
			
		||||
    private cd: ChangeDetectorRef,
 | 
			
		||||
    private relativeUrlPipe: RelativeUrlPipe,
 | 
			
		||||
  ) { }
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
@ -166,19 +169,19 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
 | 
			
		||||
 | 
			
		||||
      if (event.key === 'ArrowRight') {
 | 
			
		||||
        if (this.mempoolBlocks[this.markIndex - 1]) {
 | 
			
		||||
          this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', this.markIndex - 1]);
 | 
			
		||||
          this.router.navigate([this.relativeUrlPipe.transform('mempool-block/'), this.markIndex - 1]);
 | 
			
		||||
        } else {
 | 
			
		||||
          this.stateService.blocks$
 | 
			
		||||
            .pipe(take(this.stateService.env.MEMPOOL_BLOCKS_AMOUNT))
 | 
			
		||||
            .subscribe(([block]) => {
 | 
			
		||||
              if (this.stateService.latestBlockHeight === block.height) {
 | 
			
		||||
                this.router.navigate([(this.network ? '/' + this.network : '') + '/block/', block.id], { state: { data: { block } }});
 | 
			
		||||
                this.router.navigate([this.relativeUrlPipe.transform('/block/'), block.id], { state: { data: { block } }});
 | 
			
		||||
              }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
      } else if (event.key === 'ArrowLeft') {
 | 
			
		||||
        if (this.mempoolBlocks[this.markIndex + 1]) {
 | 
			
		||||
          this.router.navigate([(this.network ? '/' + this.network : '') + '/mempool-block/', this.markIndex + 1]);
 | 
			
		||||
          this.router.navigate([this.relativeUrlPipe.transform('/mempool-block/'), this.markIndex + 1]);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user