import { Injectable } from '@angular/core' ; import * as Rx from 'rxjs' ; type NotificationType = 'info' | 'success' | 'warning' | 'error' ; @ Injectable ( ) export class NotificationService { notifications$ = new Rx . BehaviorSubject ( null ) ; removeNotification$ = new Rx . BehaviorSubject ( null ) ; constructor ( ) { } sendNotification ( type , message , options = { } ) { this . notifications$ . next ( { type , message , options } ) ; } removeNotification ( identifier ) { this . removeNotification$ . next ( identifier ) ; } sendInfo ( message , options = { } ) { this . sendNotification ( 'info' , message , options ) ; } sendSuccess ( message , options = { } ) { this . sendNotification ( 'success' , message , options ) ; } sendWarning ( message , options = { } ) { this . sendNotification ( 'warning' , message , options ) ; } sendError ( message , options = { } ) { this . sendNotification ( 'error' , message , options ) ; } sendLedgerChromeWarning ( ) { this . sendWarning ( `<b>Notice:</b> You may experience issues using a Ledger device with Google Chrome. ` + `If you do please use Brave/Opera browser or ` + `<a href="https://github.com/cronoh/nanovault/releases" target="_blank">NanoVault Desktop</a>. ` + `&nbsp; <a href="https://github.com/cronoh/nanovault/issues/69" target="_blank">More Info</a>` , { length : 0 , identifier : 'chrome-ledger' } ) ; } }