aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/auth/auth-user.model.ts29
-rw-r--r--client/src/app/core/users/user.model.ts4
2 files changed, 32 insertions, 1 deletions
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 @@
1import { Observable, of } from 'rxjs'
2import { map } from 'rxjs/operators'
1import { User } from '@app/core/users/user.model' 3import { User } from '@app/core/users/user.model'
2import { peertubeLocalStorage } from '@app/helpers/peertube-web-storage' 4import { peertubeLocalStorage } from '@app/helpers/peertube-web-storage'
3import { 5import {
@@ -7,7 +9,8 @@ import {
7 NSFWPolicyType, 9 NSFWPolicyType,
8 User as ServerUserModel, 10 User as ServerUserModel,
9 UserRight, 11 UserRight,
10 UserRole 12 UserRole,
13 UserVideoQuota
11} from '@shared/models' 14} from '@shared/models'
12 15
13export type TokenOptions = { 16export type TokenOptions = {
@@ -74,6 +77,8 @@ export class AuthUser extends User implements ServerMyUserModel {
74 tokens: Tokens 77 tokens: Tokens
75 specialPlaylists: MyUserSpecialPlaylist[] 78 specialPlaylists: MyUserSpecialPlaylist[]
76 79
80 canSeeVideosLink = true
81
77 static load () { 82 static load () {
78 const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME) 83 const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME)
79 if (usernameLocalStorage) { 84 if (usernameLocalStorage) {
@@ -150,4 +155,26 @@ export class AuthUser extends User implements ServerMyUserModel {
150 peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) 155 peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo))
151 this.tokens.save() 156 this.tokens.save()
152 } 157 }
158
159 computeCanSeeVideosLink (quotaObservable: Observable<UserVideoQuota>): Observable<boolean> {
160 if (!this.isUploadDisabled()) {
161 this.canSeeVideosLink = true
162 return of(this.canSeeVideosLink)
163 }
164
165 // Check if the user has videos
166 return quotaObservable.pipe(
167 map(({ videoQuotaUsed }) => {
168 if (videoQuotaUsed !== 0) {
169 // User already uploaded videos, so it can see the link
170 this.canSeeVideosLink = true
171 } else {
172 // No videos, no upload so the user don't need to see the videos link
173 this.canSeeVideosLink = false
174 }
175
176 return this.canSeeVideosLink
177 })
178 )
179 }
153} 180}
diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts
index 31b9c2152..6a56786d9 100644
--- a/client/src/app/core/users/user.model.ts
+++ b/client/src/app/core/users/user.model.ts
@@ -149,4 +149,8 @@ export class User implements UserServerModel {
149 updateAccountAvatar (newAccountAvatar: Avatar) { 149 updateAccountAvatar (newAccountAvatar: Avatar) {
150 this.account.updateAvatar(newAccountAvatar) 150 this.account.updateAvatar(newAccountAvatar)
151 } 151 }
152
153 isUploadDisabled () {
154 return this.videoQuota === 0 || this.videoQuotaDaily === 0
155 }
152} 156}