]> 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
Migrate client to eslint
[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
4 @Component({
5 selector: 'my-account-danger-zone',
6 templateUrl: './my-account-danger-zone.component.html',
7 styleUrls: [ './my-account-danger-zone.component.scss' ]
8 })
9 export class MyAccountDangerZoneComponent {
10 @Input() user: User = null
11
12 constructor (
13 private authService: AuthService,
14 private notifier: Notifier,
15 private userService: UserService,
16 private confirmService: ConfirmService,
17 private redirectService: RedirectService
18 ) { }
19
20 async deleteMe () {
21 const res = await this.confirmService.confirmWithInput(
22 // eslint-disable-next-line max-len
23 $localize`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.`,
24 $localize`Type your username to confirm`,
25 this.user.username,
26 $localize`Delete your account`,
27 $localize`Delete my account`
28 )
29 if (res === false) return
30
31 this.userService.deleteMe()
32 .subscribe({
33 next: () => {
34 this.notifier.success($localize`Your account is deleted.`)
35
36 this.authService.logout()
37 this.redirectService.redirectToHomepage()
38 },
39
40 error: err => this.notifier.error(err.message)
41 })
42 }
43 }