import { AirGapWallet , AirGapWalletStatus , MainProtocolSymbols } from '@airgap/coinlib-core' ; import { Component } from '@angular/core' ; import { ModalController , NavParams } from '@ionic/angular' ; import { TranslateService } from '@ngx-translate/core' ; import { MnemonicSecret } from '../../models/secret' ; import { SecretsService } from '../../services/secrets/secrets.service' ; @ Component ( { selector : 'airgap-select-account' , templateUrl : './select-account.page.html' , styleUrls : [ './select-account.page.scss' ] } ) export class SelectAccountPage { public title : string ; public heading : string ; public placeholder : string ; public wallets : AirGapWallet [ ] ; public symbolFilter : MainProtocolSymbols | undefined ; constructor ( private readonly secretsService , private readonly translateService , private readonly navParams , private readonly modalController ) { } public async ngOnInit ( ) { const type = this . navParams . get ( 'type' ) ; this . title = this . translateService . instant ( `select-account.${ type }.title` ) ; this . heading = this . translateService . instant ( `select-account.${ type }.heading` ) ; this . placeholder = this . translateService . instant ( `select-account.${ type }.placeholder` ) ; this . secretsService . getSecretsObservable ( ) . subscribe ( ( secrets ) => { this . wallets = [ ] . concat . apply ( [ ] , secrets . map ( ( secret ) => secret . wallets . filter ( ( wallet ) => wallet . status === AirGapWalletStatus . ACTIVE && ( ! this . symbolFilter || wallet . protocol . identifier === this . symbolFilter ) ) ) as any ) ; } ) ; } public async setWallet ( wallet ) { this . modalController . dismiss ( this . navParams . get ( 'type' ) === 'message-signing' ? wallet . protocol . identifier : wallet ) . catch ( ( err ) => console . error ( err ) ) ; } public async dismiss ( ) { this . modalController . dismiss ( ) . catch ( ( err ) => console . error ( err ) ) ; } }