1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
13 import { immutableAssign } from '@app/helpers'
14 import { UserHistoryService } from '@app/shared/shared-main'
15 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
18 templateUrl: './my-history.component.html',
19 styleUrls: [ './my-history.component.scss' ]
21 export class MyHistoryComponent extends AbstractVideoList implements OnInit, OnDestroy {
23 pagination: ComponentPagination = {
28 videosHistoryEnabled: boolean
31 protected router: Router,
32 protected serverService: ServerService,
33 protected route: ActivatedRoute,
34 protected authService: AuthService,
35 protected userService: UserService,
36 protected notifier: Notifier,
37 protected screenService: ScreenService,
38 protected storageService: LocalStorageService,
39 private confirmService: ConfirmService,
40 private userHistoryService: UserHistoryService
44 this.titlePage = $localize`My videos history`
50 this.videosHistoryEnabled = this.authService.getUser().videosHistoryEnabled
57 getVideosObservable (page: number) {
58 const newPagination = immutableAssign(this.pagination, { currentPage: page })
60 return this.userHistoryService.getUserVideosHistory(newPagination)
63 generateSyndicationList () {
64 throw new Error('Method not implemented.')
67 onVideosHistoryChange () {
68 this.userService.updateMyProfile({ videosHistoryEnabled: this.videosHistoryEnabled })
71 const message = this.videosHistoryEnabled === true ?
72 $localize`Videos history is enabled` :
73 $localize`Videos history is disabled`
75 this.notifier.success(message)
77 this.authService.refreshUserInformation()
80 err => this.notifier.error(err.message)
84 async deleteHistory () {
85 const title = $localize`Delete videos history`
86 const message = $localize`Are you sure you want to delete all your videos history?`
88 const res = await this.confirmService.confirm(message, title)
89 if (res !== true) return
91 this.userHistoryService.deleteUserVideosHistory()
94 this.notifier.success($localize`Videos history deleted`)
99 err => this.notifier.error(err.message)