import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
-import { NotificationsService } from 'angular2-notifications'
import { fromEvent, Observable, Subscription } from 'rxjs'
import { AuthService } from '../../core/auth'
import { ComponentPagination } from '../rest/component-pagination.model'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { ScreenService } from '@app/shared/misc/screen.service'
import { OwnerDisplayType } from '@app/shared/video/video-miniature.component'
+import { Syndication } from '@app/shared/video/syndication.model'
+import { Notifier } from '@app/core'
export abstract class AbstractVideoList implements OnInit, OnDestroy {
private static LINES_PER_PAGE = 4
sort: VideoSortField = '-publishedAt'
categoryOneOf?: number
defaultSort: VideoSortField = '-publishedAt'
- syndicationItems = []
+ syndicationItems: Syndication[] = []
loadOnInit = true
marginContent = true
videoPages: Video[][] = []
ownerDisplayType: OwnerDisplayType = 'account'
firstLoadedPage: number
+ displayModerationBlock = false
+ trendingDays: number
+ titleTooltip: string
protected baseVideoWidth = 215
protected baseVideoHeight = 205
- protected abstract notificationsService: NotificationsService
+ protected abstract notifier: Notifier
protected abstract authService: AuthService
protected abstract router: Router
protected abstract route: ActivatedRoute
private resizeSubscription: Subscription
abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number}>
- abstract generateSyndicationList ()
+ abstract generateSyndicationList (): void
get user () {
return this.authService.getUser()
if (this.resizeSubscription) this.resizeSubscription.unsubscribe()
}
+ pageByVideoId (index: number, page: Video[]) {
+ // Video are unique in all pages
+ return page.length !== 0 ? page[0].id : 0
+ }
+
+ videoById (index: number, video: Video) {
+ return video.id
+ }
+
onNearOfTop () {
this.previousPage()
}
},
error => {
this.loadingPage[page] = false
- this.notificationsService.error(this.i18n('Error'), error.message)
+ this.notifier.error(error.message)
}
)
}
+ toggleModerationDisplay () {
+ throw new Error('toggleModerationDisplay is not implemented')
+ }
+
protected hasMoreVideos () {
// No results
if (this.pagination.totalItems === 0) return false
const min = this.minPageLoaded()
if (min > 1) {
- this.loadMoreVideos(min - 1)
+ this.loadMoreVideos(min - 1, true)
}
}
protected setNewRouteParams () {
const paramsObject = this.buildRouteParams()
- const queryParams = Object.keys(paramsObject).map(p => p + '=' + paramsObject[p]).join('&')
+ const queryParams = Object.keys(paramsObject)
+ .map(p => p + '=' + paramsObject[p])
+ .join('&')
this.location.replaceState(this.currentRoute, queryParams)
}