aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/shared/account/account.model.ts9
-rw-r--r--client/src/app/shared/video/video.model.ts12
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.model.ts11
3 files changed, 15 insertions, 17 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) {
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.model.ts b/client/src/app/videos/+video-watch/comment/video-comment.model.ts
index abecae303..4c5971f54 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.model.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.model.ts
@@ -1,4 +1,5 @@
1import { Account } from '../../../../../../shared/models/actors' 1import { Account } from '@app/shared/account/account.model'
2import { Account as AccountInterface } from '../../../../../../shared/models/actors'
2import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model' 3import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model'
3 4
4export class VideoComment implements VideoCommentServerModel { 5export class VideoComment implements VideoCommentServerModel {
@@ -10,15 +11,11 @@ export class VideoComment implements VideoCommentServerModel {
10 videoId: number 11 videoId: number
11 createdAt: Date | string 12 createdAt: Date | string
12 updatedAt: Date | string 13 updatedAt: Date | string
13 account: Account 14 account: AccountInterface
14 totalReplies: number 15 totalReplies: number
15 16
16 by: string 17 by: string
17 18
18 private static createByString (account: string, serverHost: string) {
19 return account + '@' + serverHost
20 }
21
22 constructor (hash: VideoCommentServerModel) { 19 constructor (hash: VideoCommentServerModel) {
23 this.id = hash.id 20 this.id = hash.id
24 this.url = hash.url 21 this.url = hash.url
@@ -31,6 +28,6 @@ export class VideoComment implements VideoCommentServerModel {
31 this.account = hash.account 28 this.account = hash.account
32 this.totalReplies = hash.totalReplies 29 this.totalReplies = hash.totalReplies
33 30
34 this.by = VideoComment.createByString(this.account.name, this.account.host) 31 this.by = Account.CREATE_BY_STRING(this.account.name, this.account.host)
35 } 32 }
36} 33}