]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts
Update build steps for localization
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-danger-zone / my-account-danger-zone.component.ts
CommitLineData
92b9d60c 1import { Component, Input } from '@angular/core'
67ed6552 2import { AuthService, ConfirmService, Notifier, RedirectService, User, UserService } from '@app/core'
92b9d60c 3import { I18n } from '@ngx-translate/i18n-polyfill'
92b9d60c
C
4
5@Component({
6 selector: 'my-account-danger-zone',
7 templateUrl: './my-account-danger-zone.component.html',
8 styleUrls: [ './my-account-danger-zone.component.scss' ]
9})
10export class MyAccountDangerZoneComponent {
11 @Input() user: User = null
12
13 constructor (
14 private authService: AuthService,
f8b2c1b4 15 private notifier: Notifier,
92b9d60c
C
16 private userService: UserService,
17 private confirmService: ConfirmService,
18 private redirectService: RedirectService,
19 private i18n: I18n
20 ) { }
21
22 async deleteMe () {
23 const res = await this.confirmService.confirmWithInput(
5411da31 24 this.i18n('Are you sure you want to delete your account? This will delete all your data, including channels, videos and comments. Content cached by other servers and other third-parties might make longer to be deleted.'),
92b9d60c
C
25 this.i18n('Type your username to confirm'),
26 this.user.username,
27 this.i18n('Delete your account'),
28 this.i18n('Delete my account')
29 )
30 if (res === false) return
31
32 this.userService.deleteMe().subscribe(
33 () => {
f8b2c1b4 34 this.notifier.success(this.i18n('Your account is deleted.'))
92b9d60c
C
35
36 this.authService.logout()
37 this.redirectService.redirectToHomepage()
38 },
39
f8b2c1b4 40 err => this.notifier.error(err.message)
92b9d60c
C
41 )
42 }
43}