X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fauth%2Fauth-user.model.ts;h=88b730938ab33a203abaefc3955dfc4c783a0a8f;hb=dfe3f7b72ef46401206f6f461077a7984a0c72f0;hp=4e7801550d05c5f2b5f0eeea2aa02db79c489600;hpb=0579dee3b29e301838387f53b91b58bff2ffb19a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index 4e7801550..88b730938 100644 --- a/client/src/app/core/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts @@ -1,3 +1,5 @@ +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 { @@ -7,7 +9,8 @@ import { NSFWPolicyType, User as ServerUserModel, UserRight, - UserRole + UserRole, + UserVideoQuota } from '@shared/models' export type TokenOptions = { @@ -74,6 +77,8 @@ export class AuthUser extends User implements ServerMyUserModel { tokens: Tokens specialPlaylists: MyUserSpecialPlaylist[] + canSeeVideosLink = true + static load () { const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME) if (usernameLocalStorage) { @@ -150,4 +155,26 @@ export class AuthUser extends User implements ServerMyUserModel { peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) this.tokens.save() } + + computeCanSeeVideosLink (quotaObservable: Observable): Observable { + 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 + }) + ) + } }