diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-08 10:35:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-08 10:35:54 +0100 |
commit | 76d36e0b355f41fb46709ba5e39c59b10087c6a9 (patch) | |
tree | 7a88cb3f071c458d032cf11943dec40510d3622b /client/src/app | |
parent | 93ef8a9d02059da2fc90efedb7755c97e9e19ef4 (diff) | |
download | PeerTube-76d36e0b355f41fb46709ba5e39c59b10087c6a9.tar.gz PeerTube-76d36e0b355f41fb46709ba5e39c59b10087c6a9.tar.zst PeerTube-76d36e0b355f41fb46709ba5e39c59b10087c6a9.zip |
Refractor account by
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/shared/account/account.model.ts | 9 | ||||
-rw-r--r-- | client/src/app/shared/video/video.model.ts | 12 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comment.model.ts | 11 |
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 @@ | |||
1 | import { Account } from '@app/shared/account/account.model' | ||
1 | import { User } from '../' | 2 | import { User } from '../' |
2 | import { Video as VideoServerModel } from '../../../../../shared' | 3 | import { Video as VideoServerModel } from '../../../../../shared' |
3 | import { Account } from '../../../../../shared/models/actors' | ||
4 | import { environment } from '../../../environments/environment' | ||
5 | import { getAbsoluteAPIUrl } from '../misc/utils' | 4 | import { getAbsoluteAPIUrl } from '../misc/utils' |
6 | 5 | ||
7 | export class Video implements VideoServerModel { | 6 | export 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 @@ | |||
1 | import { Account } from '../../../../../../shared/models/actors' | 1 | import { Account } from '@app/shared/account/account.model' |
2 | import { Account as AccountInterface } from '../../../../../../shared/models/actors' | ||
2 | import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model' | 3 | import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model' |
3 | 4 | ||
4 | export class VideoComment implements VideoCommentServerModel { | 5 | export 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 | } |