]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-video-miniature/abstract-video-list.ts
Fix scroll check in infinite scroller directive
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-miniature / abstract-video-list.ts
index da05e15fbd0295f87299f20d03d5e5dd2fa52859..c55e85afefc8e97c4f7f7b99cc74691dfa0d7e2b 100644 (file)
@@ -15,7 +15,7 @@ import {
 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 { ServerConfig, VideoSortField } from '@shared/models'
+import { ServerConfig, UserRight, VideoFilter, VideoSortField } from '@shared/models'
 import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
 import { Syndication, Video } from '../shared-main'
 import { MiniatureDisplayOptions, OwnerDisplayType } from './video-miniature.component'
@@ -70,9 +70,12 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
   }
 
   actions: {
-    routerLink: string
     iconName: GlobalIconName
     label: string
+    justIcon?: boolean
+    routerLink?: string
+    click?: Function
+    clipboard?: string
   }[] = []
 
   onDataSubject = new Subject<any[]>()
@@ -205,10 +208,6 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
     this.loadMoreVideos(true)
   }
 
-  toggleModerationDisplay () {
-    throw new Error('toggleModerationDisplay is not implemented')
-  }
-
   removeVideoFromArray (video: Video) {
     this.videos = this.videos.filter(v => v.id !== video.id)
   }
@@ -268,6 +267,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
     return this.groupedDateLabels[this.groupedDates[video.id]]
   }
 
+  toggleModerationDisplay () {
+    throw new Error('toggleModerationDisplay is not implemented')
+  }
+
   // On videos hook for children that want to do something
   protected onMoreVideos () { /* empty */ }
 
@@ -277,6 +280,28 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
     this.angularState = routeParams[ 'a-state' ]
   }
 
+  protected buildLocalFilter (existing: VideoFilter, base: VideoFilter) {
+    if (base === 'local') {
+      return existing === 'local'
+        ? 'all-local' as 'all-local'
+        : 'local' as 'local'
+    }
+
+    return existing === 'all'
+      ? null
+      : 'all'
+  }
+
+  protected enableAllFilterIfPossible () {
+    if (!this.authService.isLoggedIn()) return
+
+    this.authService.userInformationLoaded
+      .subscribe(() => {
+        const user = this.authService.getUser()
+        this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS)
+      })
+  }
+
   private calcPageSizes () {
     if (this.screenService.isInMobileView()) {
       this.pagination.itemsPerPage = 5