]>
Commit | Line | Data |
---|---|---|
43d0ea7f C |
1 | import { Component, ElementRef, ViewChild } from '@angular/core' |
2 | import { Notifier } from '@app/core' | |
43d0ea7f | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
589d9f55 C |
4 | import { About } from '@shared/models/server' |
5 | import { UserService } from '@app/shared' | |
43d0ea7f C |
6 | |
7 | @Component({ | |
8 | selector: 'my-instance-config-warning-modal', | |
9 | templateUrl: './instance-config-warning-modal.component.html', | |
10 | styleUrls: [ './instance-config-warning-modal.component.scss' ] | |
11 | }) | |
12 | export class InstanceConfigWarningModalComponent { | |
13 | @ViewChild('modal', { static: true }) modal: ElementRef | |
14 | ||
589d9f55 C |
15 | stopDisplayModal = false |
16 | about: About | |
17 | ||
43d0ea7f | 18 | constructor ( |
589d9f55 | 19 | private userService: UserService, |
43d0ea7f | 20 | private modalService: NgbModal, |
589d9f55 | 21 | private notifier: Notifier |
43d0ea7f C |
22 | ) { } |
23 | ||
589d9f55 C |
24 | show (about: About) { |
25 | this.about = about | |
26 | ||
27 | const ref = this.modalService.open(this.modal) | |
28 | ||
29 | ref.result.finally(() => { | |
30 | if (this.stopDisplayModal === true) this.doNotOpenAgain() | |
31 | }) | |
32 | } | |
33 | ||
592c735c C |
34 | isDefaultShortDescription (description: string) { |
35 | return description === 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly ' + | |
36 | 'in the web browser with WebTorrent and Angular.' | |
37 | } | |
38 | ||
589d9f55 C |
39 | private doNotOpenAgain () { |
40 | this.userService.updateMyProfile({ noInstanceConfigWarningModal: true }) | |
41 | .subscribe( | |
42 | () => console.log('We will not open the instance config warning modal again.'), | |
43 | ||
44 | err => this.notifier.error(err.message) | |
45 | ) | |
43d0ea7f C |
46 | } |
47 | } |