diff --git a/frontend/src/app/components/start/start.component.ts b/frontend/src/app/components/start/start.component.ts index 78c31cde5..18578adea 100644 --- a/frontend/src/app/components/start/start.component.ts +++ b/frontend/src/app/components/start/start.component.ts @@ -3,6 +3,8 @@ import { Subscription } from 'rxjs'; import { MarkBlockState, StateService } from '../../services/state.service'; import { specialBlocks } from '../../app.constants'; import { BlockExtended } from '../../interfaces/node-api.interface'; +import { Router } from '@angular/router'; +import { sleep$ } from '../../shared/common.utils'; @Component({ selector: 'app-start', @@ -61,6 +63,7 @@ export class StartComponent implements OnInit, AfterViewChecked, OnDestroy { constructor( public stateService: StateService, private cd: ChangeDetectorRef, + private router: Router ) { this.isiOS = ['iPhone','iPod','iPad'].includes((navigator as any)?.userAgentData?.platform || navigator.platform); if (this.stateService.network === '') { @@ -68,7 +71,27 @@ export class StartComponent implements OnInit, AfterViewChecked, OnDestroy { } } + async demoMode() { + // @ts-ignore + if (!window.demoMode) { + // @ts-ignore + window.demoMode = true; + const paths = ['', 'acceleration', 'mining', 'lightning']; + let i = 0; + while ('Bitcoin is still alive') { + i = (i + 1) % paths.length; + this.router.navigateByUrl(paths[i]); + await sleep$(30000); + } + } + } + ngOnInit() { + // @ts-ignore + if (window.location.search === '?demo=1') { + this.demoMode(); + } + this.firstPageWidth = 40 + (this.blockWidth * this.dynamicBlocksAmount); this.blockCounterSubscription = this.stateService.blocks$.subscribe((blocks) => { this.blockCount = blocks.length; diff --git a/frontend/src/app/shared/common.utils.ts b/frontend/src/app/shared/common.utils.ts index 5ccb369f6..080ef5663 100644 --- a/frontend/src/app/shared/common.utils.ts +++ b/frontend/src/app/shared/common.utils.ts @@ -226,6 +226,14 @@ export function insecureRandomUUID(): string { return uuid.slice(0, -1); } +export function sleep$(ms: number): Promise { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, ms); + }); +} + // https://stackoverflow.com/a/60467595 export function md5(inputString): string { var hc="0123456789abcdef";