2021-06-07 06:16:10 -07:00
|
|
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
|
|
|
import { mapGetters, mapState } from 'vuex'
|
2021-06-07 13:42:04 -07:00
|
|
|
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
2021-06-10 03:29:59 -07:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
|
|
|
faAt
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faAt
|
|
|
|
)
|
2021-06-07 06:16:10 -07:00
|
|
|
|
|
|
|
const MentionLink = {
|
|
|
|
name: 'MentionLink',
|
|
|
|
props: {
|
|
|
|
url: {
|
2021-06-10 02:08:31 -07:00
|
|
|
required: true,
|
2021-06-07 06:16:10 -07:00
|
|
|
type: String
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
required: true,
|
|
|
|
type: String
|
|
|
|
},
|
2021-06-08 07:04:57 -07:00
|
|
|
userId: {
|
|
|
|
required: false,
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
userScreenName: {
|
|
|
|
required: false,
|
|
|
|
type: String
|
2021-06-07 06:16:10 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick () {
|
2021-06-08 07:04:57 -07:00
|
|
|
const link = generateProfileLink(
|
|
|
|
this.userId || this.user.id,
|
|
|
|
this.userScreenName || this.user.screen_name
|
|
|
|
)
|
2021-06-07 06:16:10 -07:00
|
|
|
this.$router.push(link)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
user () {
|
2021-08-12 09:37:04 -07:00
|
|
|
return this.url && this.$store && this.$store.getters.findUserByUrl(this.url)
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
|
|
|
isYou () {
|
|
|
|
// FIXME why user !== currentUser???
|
2021-08-14 16:41:53 -07:00
|
|
|
return this.user && this.user.id === this.currentUser.id
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
|
|
|
userName () {
|
2021-06-08 07:04:57 -07:00
|
|
|
return this.user && this.userNameFullUi.split('@')[0]
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
|
|
|
userNameFull () {
|
2021-06-08 07:04:57 -07:00
|
|
|
return this.user && this.user.screen_name
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
|
|
|
userNameFullUi () {
|
2021-06-08 07:04:57 -07:00
|
|
|
return this.user && this.user.screen_name_ui
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
|
|
|
highlight () {
|
2021-06-08 07:04:57 -07:00
|
|
|
return this.user && this.mergedConfig.highlight[this.user.screen_name]
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
2021-06-07 13:42:04 -07:00
|
|
|
highlightType () {
|
|
|
|
return this.highlight && ('-' + this.highlight.type)
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
2021-06-07 13:42:04 -07:00
|
|
|
highlightClass () {
|
|
|
|
if (this.highlight) return highlightClass(this.user)
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
|
|
|
style () {
|
2021-06-07 13:42:04 -07:00
|
|
|
if (this.highlight) {
|
|
|
|
const {
|
|
|
|
backgroundColor,
|
|
|
|
backgroundPosition,
|
|
|
|
backgroundImage,
|
|
|
|
...rest
|
|
|
|
} = highlightStyle(this.highlight)
|
|
|
|
return rest
|
|
|
|
}
|
2021-06-07 06:16:10 -07:00
|
|
|
},
|
2021-06-08 01:38:44 -07:00
|
|
|
classnames () {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'-you': this.isYou,
|
2021-08-11 16:49:37 -07:00
|
|
|
'-highlighted': this.highlight
|
2021-06-08 01:38:44 -07:00
|
|
|
},
|
|
|
|
this.highlightType
|
|
|
|
]
|
|
|
|
},
|
2021-06-07 06:16:10 -07:00
|
|
|
...mapGetters(['mergedConfig']),
|
|
|
|
...mapState({
|
|
|
|
currentUser: state => state.users.currentUser
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MentionLink
|