direct_conversation_title.js (1021B)
1 import Vue from 'vue'
2 import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
3 import { mapState } from 'vuex'
4
5 const USER_LIMIT = 10
6
7 export default Vue.component('direct-conversation-title', {
8 name: 'DirectConversationTitle',
9 props: [
10 'users', 'fallbackUser'
11 ],
12 computed: {
13 ...mapState({
14 currentUser: state => state.users.currentUser
15 }),
16 otherUsersTruncated () {
17 return this.otherUsers.slice(0, USER_LIMIT)
18 },
19 otherUsers () {
20 let otherUsers = this.users.filter(recipient => recipient.id !== this.currentUser.id)
21 if (otherUsers.length === 0) {
22 return [this.fallbackUser]
23 } else {
24 return otherUsers
25 }
26 },
27 restCount () {
28 return this.otherUsers.length - USER_LIMIT
29 },
30 title () {
31 return this.otherUsers.map(u => u.screen_name).join(', ')
32 }
33 },
34 methods: {
35 getUserProfileLink (user) {
36 return generateProfileLink(user.id, user.screen_name)
37 }
38 }
39 })