2019-02-02 19:23:16 +00:00
|
|
|
import UserAvatar from '../user_avatar/user_avatar.vue'
|
2019-03-19 18:36:27 +00:00
|
|
|
import RemoteFollow from '../remote_follow/remote_follow.vue'
|
2019-04-25 08:19:22 +00:00
|
|
|
import ProgressButton from '../progress_button/progress_button.vue'
|
2019-10-08 07:21:48 +00:00
|
|
|
import FollowButton from '../follow_button/follow_button.vue'
|
2019-02-18 14:49:32 +00:00
|
|
|
import ModerationTools from '../moderation_tools/moderation_tools.vue'
|
2019-10-08 07:21:48 +00:00
|
|
|
import AccountActions from '../account_actions/account_actions.vue'
|
2021-03-11 14:11:44 +00:00
|
|
|
import Select from '../select/select.vue'
|
2018-12-13 16:57:11 +00:00
|
|
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
2019-09-29 19:33:15 +00:00
|
|
|
import { mapGetters } from 'vuex'
|
2020-10-19 19:35:46 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
|
|
|
faBell,
|
|
|
|
faRss,
|
|
|
|
faSearchPlus,
|
|
|
|
faExternalLinkAlt
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faRss,
|
|
|
|
faBell,
|
|
|
|
faSearchPlus,
|
|
|
|
faExternalLinkAlt
|
|
|
|
)
|
2017-11-20 20:45:09 +00:00
|
|
|
|
|
|
|
export default {
|
2019-09-21 13:24:47 +00:00
|
|
|
props: [
|
2020-04-21 20:27:51 +00:00
|
|
|
'userId', 'switcher', 'selected', 'hideBio', 'rounded', 'bordered', 'allowZoomingAvatar'
|
2019-09-21 13:24:47 +00:00
|
|
|
],
|
2018-09-03 23:32:25 +00:00
|
|
|
data () {
|
|
|
|
return {
|
2018-12-04 09:50:29 +00:00
|
|
|
followRequestInProgress: false,
|
2018-11-30 13:39:07 +00:00
|
|
|
betterShadow: this.$store.state.interface.browserSupport.cssFilter
|
2018-09-03 23:32:25 +00:00
|
|
|
}
|
|
|
|
},
|
2019-03-07 22:35:30 +00:00
|
|
|
created () {
|
|
|
|
this.$store.dispatch('fetchUserRelationship', this.user.id)
|
|
|
|
},
|
2017-11-20 20:45:09 +00:00
|
|
|
computed: {
|
2020-04-21 20:27:51 +00:00
|
|
|
user () {
|
|
|
|
return this.$store.getters.findUser(this.userId)
|
|
|
|
},
|
|
|
|
relationship () {
|
2020-04-24 15:53:17 +00:00
|
|
|
return this.$store.getters.relationship(this.userId)
|
2020-04-21 20:27:51 +00:00
|
|
|
},
|
2019-03-05 07:32:23 +00:00
|
|
|
classes () {
|
|
|
|
return [{
|
2019-07-05 07:02:14 +00:00
|
|
|
'user-card-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius
|
|
|
|
'user-card-rounded': this.rounded === true, // set border-radius for all sides
|
|
|
|
'user-card-bordered': this.bordered === true // set border for all sides
|
2019-03-05 07:32:23 +00:00
|
|
|
}]
|
|
|
|
},
|
|
|
|
style () {
|
2020-02-20 16:13:40 +00:00
|
|
|
return {
|
|
|
|
backgroundImage: [
|
|
|
|
`linear-gradient(to bottom, var(--profileTint), var(--profileTint))`,
|
|
|
|
`url(${this.user.cover_photo})`
|
|
|
|
].join(', ')
|
2017-11-20 20:45:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
isOtherUser () {
|
|
|
|
return this.user.id !== this.$store.state.users.currentUser.id
|
|
|
|
},
|
2018-02-01 19:30:49 +00:00
|
|
|
subscribeUrl () {
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
const serverUrl = new URL(this.user.statusnet_profile_url)
|
|
|
|
return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus`
|
|
|
|
},
|
2017-11-20 20:45:09 +00:00
|
|
|
loggedIn () {
|
|
|
|
return this.$store.state.users.currentUser
|
|
|
|
},
|
|
|
|
dailyAvg () {
|
|
|
|
const days = Math.ceil((new Date() - new Date(this.user.created_at)) / (60 * 60 * 24 * 1000))
|
|
|
|
return Math.round(this.user.statuses_count / days)
|
2018-06-18 08:36:58 +00:00
|
|
|
},
|
2018-08-05 02:18:04 +00:00
|
|
|
userHighlightType: {
|
2018-06-18 08:36:58 +00:00
|
|
|
get () {
|
2019-10-06 20:28:30 +00:00
|
|
|
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
|
2019-07-06 21:54:17 +00:00
|
|
|
return (data && data.type) || 'disabled'
|
2018-06-18 08:36:58 +00:00
|
|
|
},
|
2018-08-05 02:18:04 +00:00
|
|
|
set (type) {
|
2019-10-06 20:28:30 +00:00
|
|
|
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
|
2018-08-05 02:18:04 +00:00
|
|
|
if (type !== 'disabled') {
|
2019-07-06 21:54:17 +00:00
|
|
|
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: (data && data.color) || '#FFFFFF', type })
|
2018-06-18 08:36:58 +00:00
|
|
|
} else {
|
2018-06-19 13:17:50 +00:00
|
|
|
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: undefined })
|
2018-06-18 08:36:58 +00:00
|
|
|
}
|
2019-09-29 19:33:15 +00:00
|
|
|
},
|
|
|
|
...mapGetters(['mergedConfig'])
|
2018-06-18 08:36:58 +00:00
|
|
|
},
|
|
|
|
userHighlightColor: {
|
|
|
|
get () {
|
2019-10-06 20:28:30 +00:00
|
|
|
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]
|
2018-08-05 02:18:04 +00:00
|
|
|
return data && data.color
|
2018-06-18 08:36:58 +00:00
|
|
|
},
|
2018-06-19 13:17:50 +00:00
|
|
|
set (color) {
|
|
|
|
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color })
|
2018-06-18 08:36:58 +00:00
|
|
|
}
|
2019-02-04 14:03:35 +00:00
|
|
|
},
|
|
|
|
visibleRole () {
|
2019-02-18 14:49:32 +00:00
|
|
|
const rights = this.user.rights
|
|
|
|
if (!rights) { return }
|
|
|
|
const validRole = rights.admin || rights.moderator
|
|
|
|
const roleTitle = rights.admin ? 'admin' : 'moderator'
|
|
|
|
return validRole && roleTitle
|
2019-09-29 19:33:15 +00:00
|
|
|
},
|
2019-11-12 15:40:36 +00:00
|
|
|
hideFollowsCount () {
|
|
|
|
return this.isOtherUser && this.user.hide_follows_count
|
|
|
|
},
|
|
|
|
hideFollowersCount () {
|
|
|
|
return this.isOtherUser && this.user.hide_followers_count
|
|
|
|
},
|
2019-09-29 19:33:15 +00:00
|
|
|
...mapGetters(['mergedConfig'])
|
2017-11-20 20:45:09 +00:00
|
|
|
},
|
2018-03-11 23:31:33 +00:00
|
|
|
components: {
|
2019-03-19 18:36:27 +00:00
|
|
|
UserAvatar,
|
2019-02-18 14:49:32 +00:00
|
|
|
RemoteFollow,
|
2019-04-16 14:13:26 +00:00
|
|
|
ModerationTools,
|
2019-10-08 07:21:48 +00:00
|
|
|
AccountActions,
|
|
|
|
ProgressButton,
|
2021-03-11 14:11:44 +00:00
|
|
|
FollowButton,
|
|
|
|
Select
|
2018-03-11 23:31:33 +00:00
|
|
|
},
|
2017-11-20 20:45:09 +00:00
|
|
|
methods: {
|
2019-03-01 16:37:34 +00:00
|
|
|
muteUser () {
|
2019-02-24 08:02:04 +00:00
|
|
|
this.$store.dispatch('muteUser', this.user.id)
|
|
|
|
},
|
2019-03-01 16:37:34 +00:00
|
|
|
unmuteUser () {
|
2019-02-24 08:02:04 +00:00
|
|
|
this.$store.dispatch('unmuteUser', this.user.id)
|
2017-11-20 20:45:09 +00:00
|
|
|
},
|
2019-04-25 08:19:22 +00:00
|
|
|
subscribeUser () {
|
2019-04-25 08:30:08 +00:00
|
|
|
return this.$store.dispatch('subscribeUser', this.user.id)
|
2019-04-25 08:19:22 +00:00
|
|
|
},
|
|
|
|
unsubscribeUser () {
|
2019-04-25 08:30:08 +00:00
|
|
|
return this.$store.dispatch('unsubscribeUser', this.user.id)
|
2019-04-25 08:19:22 +00:00
|
|
|
},
|
2017-11-20 20:45:09 +00:00
|
|
|
setProfileView (v) {
|
2018-04-15 05:04:16 +00:00
|
|
|
if (this.switcher) {
|
|
|
|
const store = this.$store
|
|
|
|
store.commit('setProfileView', { v })
|
|
|
|
}
|
2018-12-04 08:38:00 +00:00
|
|
|
},
|
2019-07-05 07:02:14 +00:00
|
|
|
linkClicked ({ target }) {
|
2018-12-04 08:38:00 +00:00
|
|
|
if (target.tagName === 'SPAN') {
|
|
|
|
target = target.parentNode
|
|
|
|
}
|
|
|
|
if (target.tagName === 'A') {
|
|
|
|
window.open(target.href, '_blank')
|
|
|
|
}
|
2018-12-15 03:16:44 +00:00
|
|
|
},
|
|
|
|
userProfileLink (user) {
|
2019-09-21 13:24:47 +00:00
|
|
|
return generateProfileLink(
|
|
|
|
user.id, user.screen_name,
|
|
|
|
this.$store.state.instance.restrictedNicknames
|
|
|
|
)
|
2019-07-22 20:58:20 +00:00
|
|
|
},
|
2019-07-25 19:14:44 +00:00
|
|
|
zoomAvatar () {
|
2019-07-22 20:58:20 +00:00
|
|
|
const attachment = {
|
|
|
|
url: this.user.profile_image_url_original,
|
|
|
|
mimetype: 'image'
|
|
|
|
}
|
|
|
|
this.$store.dispatch('setMedia', [attachment])
|
|
|
|
this.$store.dispatch('setCurrent', attachment)
|
2019-11-27 00:57:27 +00:00
|
|
|
},
|
|
|
|
mentionUser () {
|
|
|
|
this.$store.dispatch('openPostStatusModal', { replyTo: true, repliedUser: this.user })
|
2017-11-20 20:45:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|