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