<commit_before>import { Component, Input, OnInit } from '@angular/core'
import { NotificationsService } from 'angular2-notifications'
import { UserUpdateMe } from '../../../../../../shared'
import { AuthService } from '../../../core'
import { FormReactive, User, UserService } from '../../../shared'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
import { Subject } from 'rxjs/Subject'

@Component({
  selector: 'my-account-video-settings',
  templateUrl: './my-account-video-settings.component.html',
  styleUrls: [ './my-account-video-settings.component.scss' ]
})
export class MyAccountVideoSettingsComponent extends FormReactive implements OnInit {
  @Input() user: User = null
  @Input() userInformationLoaded: Subject<any>

  constructor (
    protected formValidatorService: FormValidatorService,
    private authService: AuthService,
    private notificationsService: NotificationsService,
    private userService: UserService,
    private i18n: I18n
  ) {
    super()
  }

  ngOnInit () {
    this.buildForm({
      nsfwPolicy: null,
      autoPlayVideo: null
    })

    this.userInformationLoaded.subscribe(() => {
      this.form.patchValue({
        nsfwPolicy: this.user.nsfwPolicy,
        autoPlayVideo: this.user.autoPlayVideo === true ? 'true' : 'false'
      })
    })
  }

  updateDetails () {
    const nsfwPolicy = this.form.value['nsfwPolicy']
    const autoPlayVideo = this.form.value['autoPlayVideo']
    const details: UserUpdateMe = {
      nsfwPolicy,
      autoPlayVideo
    }

    this.userService.updateMyProfile(details).subscribe(
      () => {
        this.notificationsService.success(this.i18n('Success'), this.i18n('Information updated.'))

        this.authService.refreshUserInformation()
      },

      err => this.notificationsService.error(this.i18n('Error'), err.message)
    )<commit_msg>Fix autoplay setting in my account<commit_after>import { Component, Input, OnInit } from '@angular/core'
import { NotificationsService } from 'angular2-notifications'
import { UserUpdateMe } from '../../../../../../shared'
import { AuthService } from '../../../core'
import { FormReactive, User, UserService } from '../../../shared'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
import { Subject } from 'rxjs/Subject'

@Component({
  selector: 'my-account-video-settings',
  templateUrl: './my-account-video-settings.component.html',
  styleUrls: [ './my-account-video-settings.component.scss' ]
})
export class MyAccountVideoSettingsComponent extends FormReactive implements OnInit {
  @Input() user: User = null
  @Input() userInformationLoaded: Subject<any>

  constructor (
    protected formValidatorService: FormValidatorService,
    private authService: AuthService,
    private notificationsService: NotificationsService,
    private userService: UserService,
    private i18n: I18n
  ) {
    super()
  }

  ngOnInit () {
    this.buildForm({
      nsfwPolicy: null,
      autoPlayVideo: null
    })

    this.userInformationLoaded.subscribe(() => {
      this.form.patchValue({
        nsfwPolicy: this.user.nsfwPolicy,
        autoPlayVideo: this.user.autoPlayVideo === true
      })
    })
  }

  updateDetails () {
    const nsfwPolicy = this.form.value['nsfwPolicy']
    const autoPlayVideo = this.form.value['autoPlayVideo']
    const details: UserUpdateMe = {
      nsfwPolicy,
      autoPlayVideo
    }

    this.userService.updateMyProfile(details).subscribe(
      () => {
        this.notificationsService.success(this.i18n('Success'), this.i18n('Information updated.'))

        this.authService.refreshUserInformation()
      },

      err => this.notificationsService.error(this.i18n('Error'), err.message)
    )
{'fraction_non_alphanumeric': 0.1359173126614987, 'fraction_numerical': 0.007751937984496124, 'mean_word_length': 3.4907192575406034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '836677', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1114, 'n_words': 221}