]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - 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
1 import { Component, Input } from '@angular/core'
2 import { AuthService, ConfirmService, Notifier, RedirectService, User, UserService } from '@app/core'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
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 })
10 export class MyAccountDangerZoneComponent {
11 @Input() user: User = null
12
13 constructor (
14 private authService: AuthService,
15 private notifier: Notifier,
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(
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.'),
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 () => {
34 this.notifier.success(this.i18n('Your account is deleted.'))
35
36 this.authService.logout()
37 this.redirectService.redirectToHomepage()
38 },
39
40 err => this.notifier.error(err.message)
41 )
42 }
43 }