akkoma-fe/src/components/notification/notification.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

import Status from '../status/status.vue'
import UserAvatar from '../user_avatar/user_avatar.vue'
2019-03-05 19:01:49 +00:00
import UserCard from '../user_card/user_card.vue'
2019-06-18 20:28:31 +00:00
import Timeago from '../timeago/timeago.vue'
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
const Notification = {
data () {
return {
userExpanded: false,
betterShadow: this.$store.state.interface.browserSupport.cssFilter
}
},
props: [ 'notification' ],
components: {
2019-06-18 20:28:31 +00:00
Status,
UserAvatar,
UserCard,
Timeago
},
methods: {
toggleUserExpanded () {
this.userExpanded = !this.userExpanded
2018-12-16 23:52:27 +00:00
},
userProfileLink (user) {
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
2019-02-18 14:49:32 +00:00
},
getUser (notification) {
2019-04-12 07:49:22 +00:00
return this.$store.state.users.usersObject[notification.from_profile.id]
}
},
computed: {
userClass () {
2019-04-01 01:59:18 +00:00
return highlightClass(this.notification.from_profile)
},
userStyle () {
const highlight = this.$store.state.config.highlight
2019-04-01 01:59:18 +00:00
const user = this.notification.from_profile
return highlightStyle(highlight[user.screen_name])
2019-04-01 14:26:13 +00:00
},
userInStore () {
return this.$store.getters.findUser(this.notification.from_profile.id)
2019-04-01 14:26:13 +00:00
},
user () {
if (this.userInStore) {
return this.userInStore
}
return this.notification.from_profile
}
}
}
export default Notification