aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/actor
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-25 15:43:19 +0200
committerChocobozzz <me@florianbigard.com>2018-04-25 15:43:19 +0200
commitd3e91a5f72ac9c986cdb67d7d6c85bb4819e680c (patch)
tree3c2406346c7774587ba4e095ab595e5953e25c61 /client/src/app/shared/actor
parent03e12d7c4954e1071fdeb7ef362ea5c3965d4075 (diff)
downloadPeerTube-d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c.tar.gz
PeerTube-d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c.tar.zst
PeerTube-d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c.zip
Add video channel account list
Diffstat (limited to 'client/src/app/shared/actor')
-rw-r--r--client/src/app/shared/actor/actor.model.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.ts
new file mode 100644
index 000000000..56ff780b7
--- /dev/null
+++ b/client/src/app/shared/actor/actor.model.ts
@@ -0,0 +1,50 @@
1import { Actor as ActorServer } from '../../../../../shared/models/actors/actor.model'
2import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'
3import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
4
5export abstract class Actor implements ActorServer {
6 id: number
7 uuid: string
8 url: string
9 name: string
10 host: string
11 followingCount: number
12 followersCount: number
13 createdAt: Date
14 updatedAt: Date
15 avatar: Avatar
16
17 avatarUrl: string
18
19 static GET_ACTOR_AVATAR_URL (actor: { avatar: Avatar }) {
20 const absoluteAPIUrl = getAbsoluteAPIUrl()
21
22 if (actor && actor.avatar) return absoluteAPIUrl + actor.avatar.path
23
24 return window.location.origin + '/client/assets/images/default-avatar.png'
25 }
26
27 static CREATE_BY_STRING (accountName: string, host: string) {
28 const absoluteAPIUrl = getAbsoluteAPIUrl()
29 const thisHost = new URL(absoluteAPIUrl).host
30
31 if (host.trim() === thisHost) return accountName
32
33 return accountName + '@' + host
34 }
35
36 protected constructor (hash: ActorServer) {
37 this.id = hash.id
38 this.uuid = hash.uuid
39 this.url = hash.url
40 this.name = hash.name
41 this.host = hash.host
42 this.followingCount = hash.followingCount
43 this.followersCount = hash.followersCount
44 this.createdAt = new Date(hash.createdAt.toString())
45 this.updatedAt = new Date(hash.updatedAt.toString())
46 this.avatar = hash.avatar
47
48 this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
49 }
50}