aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorAndréas Livet <andreas.livet@gmail.com>2017-12-19 10:45:49 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:45:49 +0100
commit7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd (patch)
tree56116e7e9f8467b78ed6dfc81827288915d31c8c /client/src/app/core
parent228077efd73485a2832bb6211c9fa923158c2112 (diff)
downloadPeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.gz
PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.zst
PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.zip
Enh #106 : Add an autoPlayVideo user attribute (#159)
Warning : I was not able to run the tests on my machine. It uses a different approach to handle databse connexion and didn't find where to configure it... - create a migration file to add a boolean column in user table - add autoPlayVideo attribute everywhere it is needed (both on client and server side) - add tests - add a way to configure this attribute in account-settings - use the attribute in video-watch component to actually autoplay or not the video
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/auth/auth-user.model.ts8
-rw-r--r--client/src/app/core/auth/auth.service.ts4
2 files changed, 10 insertions, 2 deletions
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts
index 7b6c8816f..9ad275392 100644
--- a/client/src/app/core/auth/auth-user.model.ts
+++ b/client/src/app/core/auth/auth-user.model.ts
@@ -69,7 +69,8 @@ export class AuthUser extends User {
69 ROLE: 'role', 69 ROLE: 'role',
70 EMAIL: 'email', 70 EMAIL: 'email',
71 USERNAME: 'username', 71 USERNAME: 'username',
72 DISPLAY_NSFW: 'display_nsfw' 72 DISPLAY_NSFW: 'display_nsfw',
73 AUTO_PLAY_VIDEO: 'auto_play_video'
73 } 74 }
74 75
75 tokens: Tokens 76 tokens: Tokens
@@ -83,7 +84,8 @@ export class AuthUser extends User {
83 username: localStorage.getItem(this.KEYS.USERNAME), 84 username: localStorage.getItem(this.KEYS.USERNAME),
84 email: localStorage.getItem(this.KEYS.EMAIL), 85 email: localStorage.getItem(this.KEYS.EMAIL),
85 role: parseInt(localStorage.getItem(this.KEYS.ROLE), 10) as UserRole, 86 role: parseInt(localStorage.getItem(this.KEYS.ROLE), 10) as UserRole,
86 displayNSFW: localStorage.getItem(this.KEYS.DISPLAY_NSFW) === 'true' 87 displayNSFW: localStorage.getItem(this.KEYS.DISPLAY_NSFW) === 'true',
88 autoPlayVideo: localStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true'
87 }, 89 },
88 Tokens.load() 90 Tokens.load()
89 ) 91 )
@@ -97,6 +99,7 @@ export class AuthUser extends User {
97 localStorage.removeItem(this.KEYS.ID) 99 localStorage.removeItem(this.KEYS.ID)
98 localStorage.removeItem(this.KEYS.ROLE) 100 localStorage.removeItem(this.KEYS.ROLE)
99 localStorage.removeItem(this.KEYS.DISPLAY_NSFW) 101 localStorage.removeItem(this.KEYS.DISPLAY_NSFW)
102 localStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO)
100 localStorage.removeItem(this.KEYS.EMAIL) 103 localStorage.removeItem(this.KEYS.EMAIL)
101 Tokens.flush() 104 Tokens.flush()
102 } 105 }
@@ -133,6 +136,7 @@ export class AuthUser extends User {
133 localStorage.setItem(AuthUser.KEYS.EMAIL, this.email) 136 localStorage.setItem(AuthUser.KEYS.EMAIL, this.email)
134 localStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) 137 localStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString())
135 localStorage.setItem(AuthUser.KEYS.DISPLAY_NSFW, JSON.stringify(this.displayNSFW)) 138 localStorage.setItem(AuthUser.KEYS.DISPLAY_NSFW, JSON.stringify(this.displayNSFW))
139 localStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo))
136 this.tokens.save() 140 this.tokens.save()
137 } 141 }
138} 142}
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index e2b8b6ba5..37264a8ad 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -33,6 +33,7 @@ interface UserLoginWithUserInformation extends UserLogin {
33 id: number 33 id: number
34 role: UserRole 34 role: UserRole
35 displayNSFW: boolean 35 displayNSFW: boolean
36 autoPlayVideo: boolean
36 email: string 37 email: string
37 videoQuota: number 38 videoQuota: number
38 account: Account 39 account: Account
@@ -191,6 +192,7 @@ export class AuthService {
191 .subscribe( 192 .subscribe(
192 res => { 193 res => {
193 this.user.displayNSFW = res.displayNSFW 194 this.user.displayNSFW = res.displayNSFW
195 this.user.autoPlayVideo = res.autoPlayVideo
194 this.user.role = res.role 196 this.user.role = res.role
195 this.user.videoChannels = res.videoChannels 197 this.user.videoChannels = res.videoChannels
196 this.user.account = res.account 198 this.user.account = res.account
@@ -212,6 +214,7 @@ export class AuthService {
212 id: res.id, 214 id: res.id,
213 role: res.role, 215 role: res.role,
214 displayNSFW: res.displayNSFW, 216 displayNSFW: res.displayNSFW,
217 autoPlayVideo: res.autoPlayVideo,
215 email: res.email, 218 email: res.email,
216 videoQuota: res.videoQuota, 219 videoQuota: res.videoQuota,
217 account: res.account, 220 account: res.account,
@@ -230,6 +233,7 @@ export class AuthService {
230 role: obj.role, 233 role: obj.role,
231 email: obj.email, 234 email: obj.email,
232 displayNSFW: obj.displayNSFW, 235 displayNSFW: obj.displayNSFW,
236 autoPlayVideo: obj.autoPlayVideo,
233 videoQuota: obj.videoQuota, 237 videoQuota: obj.videoQuota,
234 videoChannels: obj.videoChannels, 238 videoChannels: obj.videoChannels,
235 account: obj.account 239 account: obj.account