]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/account/account-settings/account-details/account-details.component.ts
Add ability to choose what policy we have for NSFW videos
[github/Chocobozzz/PeerTube.git] / client / src / app / account / account-settings / account-details / account-details.component.ts
index d835c53e502440b5b333bd84be17069c984bb596..de213717ec1a9f1d65b06473c1141f33447959d7 100644 (file)
@@ -14,8 +14,6 @@ import { FormReactive, User, UserService } from '../../../shared'
 export class AccountDetailsComponent extends FormReactive implements OnInit {
   @Input() user: User = null
 
-  error: string = null
-
   form: FormGroup
   formErrors = {}
   validationMessages = {}
@@ -31,7 +29,8 @@ export class AccountDetailsComponent extends FormReactive implements OnInit {
 
   buildForm () {
     this.form = this.formBuilder.group({
-      displayNSFW: [ this.user.displayNSFW ]
+      nsfwPolicy: [ this.user.nsfwPolicy ],
+      autoPlayVideo: [ this.user.autoPlayVideo ]
     })
 
     this.form.valueChanges.subscribe(data => this.onValueChanged(data))
@@ -42,12 +41,13 @@ export class AccountDetailsComponent extends FormReactive implements OnInit {
   }
 
   updateDetails () {
-    const displayNSFW = this.form.value['displayNSFW']
+    const nsfwPolicy = this.form.value['nsfwPolicy']
+    const autoPlayVideo = this.form.value['autoPlayVideo']
     const details: UserUpdateMe = {
-      displayNSFW
+      nsfwPolicy,
+      autoPlayVideo
     }
 
-    this.error = null
     this.userService.updateMyDetails(details).subscribe(
       () => {
         this.notificationsService.success('Success', 'Information updated.')
@@ -55,7 +55,7 @@ export class AccountDetailsComponent extends FormReactive implements OnInit {
         this.authService.refreshUserInformation()
       },
 
-      err => this.error = err.message
+      err => this.notificationsService.error('Error', err.message)
     )
   }
 }