mirror of
https://github.com/mempool/mempool.git
synced 2024-11-19 01:41:01 +01:00
Merge pull request #5601 from mempool/nymkappa/demo-mode
implement very simple demo mode
This commit is contained in:
commit
5fba9595af
@ -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;
|
||||
|
@ -226,6 +226,14 @@ export function insecureRandomUUID(): string {
|
||||
return uuid.slice(0, -1);
|
||||
}
|
||||
|
||||
export function sleep$(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, ms);
|
||||
});
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/60467595
|
||||
export function md5(inputString): string {
|
||||
var hc="0123456789abcdef";
|
||||
|
Loading…
Reference in New Issue
Block a user