aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-08 10:35:54 +0100
committerChocobozzz <me@florianbigard.com>2018-01-08 10:35:54 +0100
commit76d36e0b355f41fb46709ba5e39c59b10087c6a9 (patch)
tree7a88cb3f071c458d032cf11943dec40510d3622b /client/src/app/shared
parent93ef8a9d02059da2fc90efedb7755c97e9e19ef4 (diff)
downloadPeerTube-76d36e0b355f41fb46709ba5e39c59b10087c6a9.tar.gz
PeerTube-76d36e0b355f41fb46709ba5e39c59b10087c6a9.tar.zst
PeerTube-76d36e0b355f41fb46709ba5e39c59b10087c6a9.zip
Refractor account by
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/account/account.model.ts9
-rw-r--r--client/src/app/shared/video/video.model.ts12
2 files changed, 11 insertions, 10 deletions
diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.ts
index 1dce0003c..dffca783b 100644
--- a/client/src/app/shared/account/account.model.ts
+++ b/client/src/app/shared/account/account.model.ts
@@ -22,4 +22,13 @@ export class Account implements ServerAccount {
22 22
23 return window.location.origin + '/client/assets/images/default-avatar.png' 23 return window.location.origin + '/client/assets/images/default-avatar.png'
24 } 24 }
25
26 static CREATE_BY_STRING (accountName: string, host: string) {
27 const absoluteAPIUrl = getAbsoluteAPIUrl()
28 const thisHost = new URL(absoluteAPIUrl).host
29
30 if (host.trim() === thisHost) return accountName
31
32 return accountName + '@' + host
33 }
25} 34}
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index a4b90ad94..79351ba2a 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -1,7 +1,6 @@
1import { Account } from '@app/shared/account/account.model'
1import { User } from '../' 2import { User } from '../'
2import { Video as VideoServerModel } from '../../../../../shared' 3import { Video as VideoServerModel } from '../../../../../shared'
3import { Account } from '../../../../../shared/models/actors'
4import { environment } from '../../../environments/environment'
5import { getAbsoluteAPIUrl } from '../misc/utils' 4import { getAbsoluteAPIUrl } from '../misc/utils'
6 5
7export class Video implements VideoServerModel { 6export class Video implements VideoServerModel {
@@ -35,13 +34,6 @@ export class Video implements VideoServerModel {
35 nsfw: boolean 34 nsfw: boolean
36 account: Account 35 account: Account
37 36
38 private static createByString (account: string, serverHost: string, apiURL: string) {
39 const thisHost = new URL(apiURL).host
40 if (serverHost.trim() === thisHost)
41 return account
42 return account + '@' + serverHost
43 }
44
45 private static createDurationString (duration: number) { 37 private static createDurationString (duration: number) {
46 const minutes = Math.floor(duration / 60) 38 const minutes = Math.floor(duration / 60)
47 const seconds = duration % 60 39 const seconds = duration % 60
@@ -81,7 +73,7 @@ export class Video implements VideoServerModel {
81 this.dislikes = hash.dislikes 73 this.dislikes = hash.dislikes
82 this.nsfw = hash.nsfw 74 this.nsfw = hash.nsfw
83 75
84 this.by = Video.createByString(hash.accountName, hash.serverHost, absoluteAPIUrl) 76 this.by = Account.CREATE_BY_STRING(hash.accountName, hash.serverHost)
85 } 77 }
86 78
87 isVideoNSFWForUser (user: User) { 79 isVideoNSFWForUser (user: User) {