yandere_fe/src/components/notification/notification.js

89 lines
2.8 KiB
JavaScript
Raw Normal View History

2020-05-25 15:01:25 -07:00
import StatusContent from '../status_content/status_content.vue'
import Status from '../status/status.vue'
import UserAvatar from '../user_avatar/user_avatar.vue'
2019-03-05 11:01:49 -08:00
import UserCard from '../user_card/user_card.vue'
2019-06-18 13:28:31 -07:00
import Timeago from '../timeago/timeago.vue'
import { isStatusNotification } from '../../services/notification_utils/notification_utils.js'
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,
unmuted: false
}
},
props: [ 'notification' ],
components: {
2020-05-25 15:01:25 -07:00
StatusContent,
2019-06-18 13:28:31 -07:00
UserAvatar,
UserCard,
2020-05-25 15:01:25 -07:00
Timeago,
Status,
},
methods: {
toggleUserExpanded () {
this.userExpanded = !this.userExpanded
2018-12-16 15:52:27 -08:00
},
generateUserProfileLink (user) {
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
2019-02-18 06:49:32 -08:00
},
getUser (notification) {
2019-04-12 00:49:22 -07:00
return this.$store.state.users.usersObject[notification.from_profile.id]
},
toggleMute () {
this.unmuted = !this.unmuted
},
approveUser () {
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
this.$store.dispatch('removeFollowRequest', this.user)
this.$store.dispatch('markSingleNotificationAsSeen', { id: this.notification.id })
this.$store.dispatch('updateNotification', {
id: this.notification.id,
updater: notification => {
notification.type = 'follow'
}
})
},
denyUser () {
this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
.then(() => {
this.$store.dispatch('dismissNotificationLocal', { id: this.notification.id })
this.$store.dispatch('removeFollowRequest', this.user)
})
}
},
computed: {
userClass () {
2019-03-31 18:59:18 -07:00
return highlightClass(this.notification.from_profile)
},
userStyle () {
const highlight = this.$store.getters.mergedConfig.highlight
2019-03-31 18:59:18 -07:00
const user = this.notification.from_profile
return highlightStyle(highlight[user.screen_name])
2019-04-01 07:26:13 -07:00
},
user () {
2019-12-11 01:48:18 -08:00
return this.$store.getters.findUser(this.notification.from_profile.id)
},
userProfileLink () {
2019-09-10 13:21:52 -07:00
return this.generateUserProfileLink(this.user)
},
2019-12-10 11:02:25 -08:00
targetUser () {
2019-12-11 01:48:18 -08:00
return this.$store.getters.findUser(this.notification.target.id)
2019-12-10 11:02:25 -08:00
},
targetUserProfileLink () {
return this.generateUserProfileLink(this.targetUser)
},
needMute () {
return this.$store.getters.relationship(this.user.id).muting
},
isStatusNotification () {
return isStatusNotification(this.notification.type)
}
}
}
export default Notification