Merge pull request #5601 from mempool/nymkappa/demo-mode

implement very simple demo mode
This commit is contained in:
wiz 2024-10-22 15:16:45 +09:00 committed by GitHub
commit 5fba9595af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View File

@ -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;

View File

@ -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";