X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fabstract-video-list.ts;h=d74384293c0219112600a24e844cecc42fb829ef;hb=9b4b15f91c485f9a7fe2ed314b4101f4b7506b38;hp=53b0444785859e96b97bb435c709eccdfac293f6;hpb=d5931e623320d0851a19e1001e90c7d8138d7a20;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index 53b044478..d74384293 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts @@ -3,7 +3,6 @@ import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core' 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' @@ -12,6 +11,8 @@ import { Video } from './video.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 @@ -27,7 +28,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { sort: VideoSortField = '-publishedAt' categoryOneOf?: number defaultSort: VideoSortField = '-publishedAt' - syndicationItems = [] + syndicationItems: Syndication[] = [] loadOnInit = true marginContent = true @@ -37,11 +38,14 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { 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 @@ -58,7 +62,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { private resizeSubscription: Subscription abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number}> - abstract generateSyndicationList () + abstract generateSyndicationList (): void get user () { return this.authService.getUser() @@ -81,6 +85,15 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { 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() } @@ -146,11 +159,15 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { }, 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 @@ -166,7 +183,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { const min = this.minPageLoaded() if (min > 1) { - this.loadMoreVideos(min - 1) + this.loadMoreVideos(min - 1, true) } } @@ -197,7 +214,9 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { 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) }