import { Component , OnInit } from '@angular/core' ; import { first } from 'rxjs/operators' ; import { MnemonicSecret } from '../../models/secret' ; import { DeviceService } from '../../services/device/device.service' ; import { ErrorCategory , handleErrorLocal } from '../../services/error-handler/error-handler.service' ; import { NavigationService } from '../../services/navigation/navigation.service' ; import { SecretsService } from '../../services/secrets/secrets.service' ; import { VaultStorageKey , VaultStorageService } from '../../services/storage/storage.service' ; @ Component ( { selector : 'airgap-secret-setup' , templateUrl : './secret-setup.page.html' , styleUrls : [ './secret-setup.page.scss' ] } ) export class SecretSetupPage implements OnInit { public canGoBack : boolean = false ; public isAdvancedMode : boolean = false ; constructor ( private readonly navigationService , private readonly secretsService , private readonly deviceService , private readonly storageService ) { } public ngOnInit ( ) { this . secretsService . getSecretsObservable ( ) . pipe ( first ( ) ) . subscribe ( ( secrets ) => { if ( secrets . length > 0 ) { this . canGoBack = true ; } } ) ; } public ionViewDidEnter ( ) { this . deviceService . setSecureWindow ( ) ; } public ionViewWillLeave ( ) { this . deviceService . clearSecureWindow ( ) ; } public async goToGenerate ( ) { const hasShownDisclaimer = await this . storageService . get ( VaultStorageKey . DISCLAIMER_GENERATE_INITIAL ) ; if ( hasShownDisclaimer ) { this . navigationService . route ( '/secret-generate' ) . catch ( handleErrorLocal ( ErrorCategory . IONIC_NAVIGATION ) ) ; } else { this . navigationService . route ( '/secret-generate-onboarding' ) . catch ( handleErrorLocal ( ErrorCategory . IONIC_NAVIGATION ) ) ; } } public goToImport ( ) { this . navigationService . route ( '/secret-import' ) . catch ( handleErrorLocal ( ErrorCategory . IONIC_NAVIGATION ) ) ; } public goToSocialRecoveryImport ( ) { this . navigationService . route ( '/social-recovery-import' ) . catch ( handleErrorLocal ( ErrorCategory . IONIC_NAVIGATION ) ) ; } public goToDiceRollPage ( ) { this . navigationService . route ( '/secret-generate-dice' ) . catch ( handleErrorLocal ( ErrorCategory . IONIC_NAVIGATION ) ) ; } public goToCoinFlipPage ( ) { this . navigationService . route ( '/secret-generate-coin-flip' ) . catch ( handleErrorLocal ( ErrorCategory . IONIC_NAVIGATION ) ) ; } }