User Card: redux.

This commit is contained in:
lain 2020-06-30 14:06:50 +02:00
parent c1b28879f9
commit c4d7331fd6

View file

@ -18,7 +18,7 @@ export default {
} }
}, },
created () { created () {
this.$store.dispatch('fetchUserRelationship', this.user.id) this.$store.dispatch('fetchUserRelationship', this.user.redux.id)
}, },
computed: { computed: {
user () { user () {
@ -38,61 +38,61 @@ export default {
return { return {
backgroundImage: [ backgroundImage: [
`linear-gradient(to bottom, var(--profileTint), var(--profileTint))`, `linear-gradient(to bottom, var(--profileTint), var(--profileTint))`,
`url(${this.user.cover_photo})` `url(${this.user.redux.header})`
].join(', ') ].join(', ')
} }
}, },
isOtherUser () { isOtherUser () {
return this.user.id !== this.$store.state.users.currentUser.id return this.user.redux.id !== this.$store.state.users.currentUser.id
}, },
subscribeUrl () { subscribeUrl () {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const serverUrl = new URL(this.user.statusnet_profile_url) const serverUrl = new URL(this.user.redux.url)
return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus` return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus`
}, },
loggedIn () { loggedIn () {
return this.$store.state.users.currentUser return this.$store.state.users.currentUser
}, },
dailyAvg () { dailyAvg () {
const days = Math.ceil((new Date() - new Date(this.user.created_at)) / (60 * 60 * 24 * 1000)) const days = Math.ceil((new Date() - new Date(this.user.redux.created_at)) / (60 * 60 * 24 * 1000))
return Math.round(this.user.statuses_count / days) return Math.round(this.user.redux.statuses_count / days)
}, },
userHighlightType: { userHighlightType: {
get () { get () {
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name] const data = this.$store.getters.mergedConfig.highlight[this.user.redux.acct]
return (data && data.type) || 'disabled' return (data && data.type) || 'disabled'
}, },
set (type) { set (type) {
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name] const data = this.$store.getters.mergedConfig.highlight[this.user.redux.acct]
if (type !== 'disabled') { if (type !== 'disabled') {
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: (data && data.color) || '#FFFFFF', type }) this.$store.dispatch('setHighlight', { user: this.user.redux.acct, color: (data && data.color) || '#FFFFFF', type })
} else { } else {
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: undefined }) this.$store.dispatch('setHighlight', { user: this.user.redux.acct, color: undefined })
} }
}, },
...mapGetters(['mergedConfig']) ...mapGetters(['mergedConfig'])
}, },
userHighlightColor: { userHighlightColor: {
get () { get () {
const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name] const data = this.$store.getters.mergedConfig.highlight[this.user.redux.acct]
return data && data.color return data && data.color
}, },
set (color) { set (color) {
this.$store.dispatch('setHighlight', { user: this.user.screen_name, color }) this.$store.dispatch('setHighlight', { user: this.user.redux.acct, color })
} }
}, },
visibleRole () { visibleRole () {
const rights = this.user.rights const rights = this.user.redux.pleroma
if (!rights) { return } if (!rights) { return }
const validRole = rights.admin || rights.moderator const validRole = rights.is_admin || rights.is_moderator
const roleTitle = rights.admin ? 'admin' : 'moderator' const roleTitle = rights.is_admin ? 'admin' : 'moderator'
return validRole && roleTitle return validRole && roleTitle
}, },
hideFollowsCount () { hideFollowsCount () {
return this.isOtherUser && this.user.hide_follows_count return this.isOtherUser && this.user.redux.hide_follows_count
}, },
hideFollowersCount () { hideFollowersCount () {
return this.isOtherUser && this.user.hide_followers_count return this.isOtherUser && this.user.redux.hide_followers_count
}, },
...mapGetters(['mergedConfig']) ...mapGetters(['mergedConfig'])
}, },
@ -106,16 +106,16 @@ export default {
}, },
methods: { methods: {
muteUser () { muteUser () {
this.$store.dispatch('muteUser', this.user.id) this.$store.dispatch('muteUser', this.user.redux.id)
}, },
unmuteUser () { unmuteUser () {
this.$store.dispatch('unmuteUser', this.user.id) this.$store.dispatch('unmuteUser', this.user.redux.id)
}, },
subscribeUser () { subscribeUser () {
return this.$store.dispatch('subscribeUser', this.user.id) return this.$store.dispatch('subscribeUser', this.user.redux.id)
}, },
unsubscribeUser () { unsubscribeUser () {
return this.$store.dispatch('unsubscribeUser', this.user.id) return this.$store.dispatch('unsubscribeUser', this.user.redux.id)
}, },
setProfileView (v) { setProfileView (v) {
if (this.switcher) { if (this.switcher) {
@ -133,14 +133,16 @@ export default {
}, },
userProfileLink (user) { userProfileLink (user) {
return generateProfileLink( return generateProfileLink(
user.id, user.screen_name, user.redux.id, user.redux.acct,
this.$store.state.instance.restrictedNicknames this.$store.state.instance.restrictedNicknames
) )
}, },
zoomAvatar () { zoomAvatar () {
const attachment = { const attachment = {
url: this.user.profile_image_url_original, url: this.user.redux.avatar,
mimetype: 'image' pleroma: {
mime_type: 'image'
}
} }
this.$store.dispatch('setMedia', [attachment]) this.$store.dispatch('setMedia', [attachment])
this.$store.dispatch('setCurrent', attachment) this.$store.dispatch('setCurrent', attachment)