2021-06-07 13:16:10 +00:00
|
|
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
|
|
|
import { mapGetters, mapState } from 'vuex'
|
2021-06-07 20:42:04 +00:00
|
|
|
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
2021-06-07 13:16:10 +00:00
|
|
|
|
|
|
|
const MentionLink = {
|
|
|
|
name: 'MentionLink',
|
|
|
|
props: {
|
|
|
|
url: {
|
|
|
|
required: true,
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
required: true,
|
|
|
|
type: String
|
|
|
|
},
|
2021-06-08 08:38:44 +00:00
|
|
|
firstMention: {
|
|
|
|
required: false,
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2021-06-07 13:16:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick () {
|
|
|
|
const link = generateProfileLink(this.user.id, this.user.screen_name)
|
|
|
|
this.$router.push(link)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
user () {
|
|
|
|
return this.$store.getters.findUserByUrl(this.url)
|
|
|
|
},
|
|
|
|
isYou () {
|
|
|
|
// FIXME why user !== currentUser???
|
|
|
|
return this.user.screen_name === this.currentUser.screen_name
|
|
|
|
},
|
|
|
|
userName () {
|
|
|
|
return this.userNameFullUi.split('@')[0]
|
|
|
|
},
|
|
|
|
userNameFull () {
|
|
|
|
return this.user.screen_name
|
|
|
|
},
|
|
|
|
userNameFullUi () {
|
|
|
|
return this.user.screen_name_ui
|
|
|
|
},
|
|
|
|
highlight () {
|
|
|
|
return this.mergedConfig.highlight[this.user.screen_name]
|
|
|
|
},
|
2021-06-07 20:42:04 +00:00
|
|
|
highlightType () {
|
|
|
|
return this.highlight && ('-' + this.highlight.type)
|
2021-06-07 13:16:10 +00:00
|
|
|
},
|
2021-06-07 20:42:04 +00:00
|
|
|
highlightClass () {
|
|
|
|
if (this.highlight) return highlightClass(this.user)
|
2021-06-07 13:16:10 +00:00
|
|
|
},
|
2021-06-08 09:58:28 +00:00
|
|
|
oldPlace () {
|
2021-06-08 11:51:42 +00:00
|
|
|
return !this.mergedConfig.mentionsOwnLine
|
2021-06-08 09:58:28 +00:00
|
|
|
},
|
|
|
|
oldStyle () {
|
2021-06-08 11:51:42 +00:00
|
|
|
return !this.mergedConfig.mentionsNewStyle
|
2021-06-08 09:58:28 +00:00
|
|
|
},
|
2021-06-07 13:16:10 +00:00
|
|
|
style () {
|
2021-06-07 20:42:04 +00:00
|
|
|
if (this.highlight) {
|
|
|
|
const {
|
|
|
|
backgroundColor,
|
|
|
|
backgroundPosition,
|
|
|
|
backgroundImage,
|
|
|
|
...rest
|
|
|
|
} = highlightStyle(this.highlight)
|
|
|
|
return rest
|
|
|
|
}
|
2021-06-07 13:16:10 +00:00
|
|
|
},
|
2021-06-08 08:38:44 +00:00
|
|
|
classnames () {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'-you': this.isYou,
|
|
|
|
'-highlighted': this.highlight,
|
2021-06-08 09:58:28 +00:00
|
|
|
'-firstMention': this.firstMention,
|
|
|
|
'-oldStyle': this.oldStyle
|
2021-06-08 08:38:44 +00:00
|
|
|
},
|
|
|
|
this.highlightType
|
|
|
|
]
|
|
|
|
},
|
2021-06-07 13:16:10 +00:00
|
|
|
...mapGetters(['mergedConfig']),
|
|
|
|
...mapState({
|
|
|
|
currentUser: state => state.users.currentUser
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MentionLink
|