} from '@app/core'
import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
import { GlobalIconName } from '@app/shared/shared-icons'
-import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@shared/core-utils/miscs/date'
+import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@shared/core-utils'
import { HTMLServerConfig, UserRight, VideoFilter, VideoSortField } from '@shared/models'
import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
import { Syndication, Video } from '../shared-main'
}
@Directive()
-// tslint:disable-next-line: directive-class-suffix
+// eslint-disable-next-line @angular-eslint/directive-class-suffix
export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterContentInit, DisableForReuseHook {
@ViewChild('videoListHeader', { static: true, read: ViewContainerRef }) videoListHeader: ViewContainerRef
ngAfterContentInit () {
if (this.videoListHeader) {
// some components don't use the header: they use their own template, like my-history.component.html
- this.setHeader.apply(this, [ this.HeaderComponent, this.headerComponentInjector ])
+ this.setHeader(this.HeaderComponent, this.headerComponentInjector)
}
}
}
loadMoreVideos (reset = false) {
- this.getVideosObservable(this.pagination.currentPage).subscribe(
- ({ data }) => {
- this.hasDoneFirstQuery = true
- this.lastQueryLength = data.length
+ this.getVideosObservable(this.pagination.currentPage)
+ .subscribe({
+ next: ({ data }) => {
+ this.hasDoneFirstQuery = true
+ this.lastQueryLength = data.length
- if (reset) this.videos = []
- this.videos = this.videos.concat(data)
+ if (reset) this.videos = []
+ this.videos = this.videos.concat(data)
- if (this.groupByDate) this.buildGroupedDateLabels()
+ if (this.groupByDate) this.buildGroupedDateLabels()
- this.onMoreVideos()
+ this.onMoreVideos()
- this.onDataSubject.next(data)
- },
+ this.onDataSubject.next(data)
+ },
- error => {
- const message = $localize`Cannot load more videos. Try again later.`
+ error: err => {
+ const message = $localize`Cannot load more videos. Try again later.`
- console.error(message, { error })
- this.notifier.error(message)
- }
- )
+ console.error(message, { err })
+ this.notifier.error(message)
+ }
+ })
}
reloadVideos () {
if (currentGroupedDate !== period.value) {
currentGroupedDate = period.value
- this.groupedDates[ video.id ] = currentGroupedDate
+ this.groupedDates[video.id] = currentGroupedDate
}
break
i: Injector = this.headerComponentInjector
) {
const injector = i || Injector.create({
- providers: [{
+ providers: [ {
provide: 'data',
useValue: {
titlePage: this.titlePage,
titleTooltip: this.titleTooltip
}
- }]
+ } ]
})
const viewContainerRef = this.videoListHeader
viewContainerRef.clear()
protected loadPageRouteParams (_queryParams: Params) { /* empty */ }
protected loadRouteParams (queryParams: Params) {
- this.sort = queryParams[ 'sort' ] as VideoSortField || this.defaultSort
- this.categoryOneOf = queryParams[ 'categoryOneOf' ]
- this.angularState = queryParams[ 'a-state' ]
+ this.sort = queryParams['sort'] as VideoSortField || this.defaultSort
+ this.categoryOneOf = queryParams['categoryOneOf']
+ this.angularState = queryParams['a-state']
this.loadPageRouteParams(queryParams)
}