+import { Observable, of } from 'rxjs'
+import { map } from 'rxjs/operators'
import { User } from '@app/core/users/user.model'
import { peertubeLocalStorage } from '@app/helpers/peertube-web-storage'
import {
NSFWPolicyType,
User as ServerUserModel,
UserRight,
- UserRole
+ UserRole,
+ UserVideoQuota
} from '@shared/models'
export type TokenOptions = {
tokens: Tokens
specialPlaylists: MyUserSpecialPlaylist[]
+ canSeeVideosLink = true
+
static load () {
const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME)
if (usernameLocalStorage) {
peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo))
this.tokens.save()
}
+
+ computeCanSeeVideosLink (quotaObservable: Observable<UserVideoQuota>): Observable<boolean> {
+ if (!this.isUploadDisabled()) {
+ this.canSeeVideosLink = true
+ return of(this.canSeeVideosLink)
+ }
+
+ // Check if the user has videos
+ return quotaObservable.pipe(
+ map(({ videoQuotaUsed }) => {
+ if (videoQuotaUsed !== 0) {
+ // User already uploaded videos, so it can see the link
+ this.canSeeVideosLink = true
+ } else {
+ // No videos, no upload so the user don't need to see the videos link
+ this.canSeeVideosLink = false
+ }
+
+ return this.canSeeVideosLink
+ })
+ )
+ }
}