]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/core/confirm/confirm.service.ts
Use commonjs instead of esm typescript for light emojis
[github/Chocobozzz/PeerTube.git] / client / src / app / core / confirm / confirm.service.ts
1 import { first } from 'rxjs/operators'
2 import { Injectable } from '@angular/core'
3 import { Subject } from 'rxjs'
4
5 type ConfirmOptions = {
6 title: string
7 message: string
8 inputLabel?: string
9 expectedInputValue?: string
10 confirmButtonText?: string
11 }
12
13 @Injectable()
14 export class ConfirmService {
15 showConfirm = new Subject<ConfirmOptions>()
16 confirmResponse = new Subject<boolean>()
17
18 confirm (message: string, title = '', confirmButtonText?: string) {
19 this.showConfirm.next({ title, message, confirmButtonText })
20
21 return this.confirmResponse.asObservable()
22 .pipe(first())
23 .toPromise()
24 }
25
26 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
27 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
28
29 return this.confirmResponse.asObservable()
30 .pipe(first())
31 .toPromise()
32 }
33 }