import { Component } from '@angular/core' ; import { Platform } from '@ionic/angular' ; import { MnemonicSecret } from '../../models/secret' ; import { ErrorCategory , handleErrorLocal } from '../../services/error-handler/error-handler.service' ; import { NavigationService } from '../../services/navigation/navigation.service' ; import { SecretsService } from '../../services/secrets/secrets.service' ; @ Component ( { selector : 'airgap-secret-add' , templateUrl : './secret-add.page.html' , styleUrls : [ './secret-add.page.scss' ] } ) export class SecretAddPage { public isGenerating : boolean = false ; public isAndroid : boolean = false ; public secret : MnemonicSecret ; constructor ( private readonly secretsService , private readonly navigationService , private readonly platform ) { if ( this . navigationService . getState ( ) ) { this . isGenerating = this . navigationService . getState ( ) . isGenerating ; this . secret = this . navigationService . getState ( ) . secret ; this . isAndroid = this . platform . is ( 'android' ) ; } } public async confirm ( ) { try { await this . secretsService . addOrUpdateSecret ( this . secret ) ; } catch ( error ) { handleErrorLocal ( ErrorCategory . SECURE_STORAGE ) ( error ) ; return ; } await this . dismiss ( ) ; if ( this . isGenerating ) { this . navigationService . route ( '/account-add' ) . catch ( handleErrorLocal ( ErrorCategory . IONIC_NAVIGATION ) ) ; } } public async dismiss ( ) { try { return this . navigationService . routeToAccountsTab ( ) ; } catch ( error ) { return false ; } } public async togglePasscode ( ) { this . secret . isParanoia = ! this . secret . isParanoia ; } }