2018-04-09 17:44:37 +00:00
|
|
|
import Status from '../status/status.vue'
|
2019-02-02 20:33:02 +00:00
|
|
|
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'
|
2020-04-25 04:04:39 +00:00
|
|
|
import { isStatusNotification } from '../../services/notification_utils/notification_utils.js'
|
2018-06-18 09:09:14 +00:00
|
|
|
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
2018-12-13 16:57:11 +00:00
|
|
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
2018-04-09 17:44:37 +00:00
|
|
|
|
|
|
|
const Notification = {
|
|
|
|
data () {
|
|
|
|
return {
|
2018-11-30 13:39:07 +00:00
|
|
|
userExpanded: false,
|
2019-09-06 15:15:22 +00:00
|
|
|
betterShadow: this.$store.state.interface.browserSupport.cssFilter,
|
|
|
|
unmuted: false
|
2018-04-09 17:44:37 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-28 19:39:54 +00:00
|
|
|
props: [ 'notification' ],
|
2018-04-09 17:44:37 +00:00
|
|
|
components: {
|
2019-06-18 20:28:31 +00:00
|
|
|
Status,
|
|
|
|
UserAvatar,
|
|
|
|
UserCard,
|
|
|
|
Timeago
|
2018-04-09 17:44:37 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleUserExpanded () {
|
|
|
|
this.userExpanded = !this.userExpanded
|
2018-12-16 23:52:27 +00:00
|
|
|
},
|
2019-09-06 15:15:22 +00:00
|
|
|
generateUserProfileLink (user) {
|
2018-12-26 13:50:48 +00:00
|
|
|
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]
|
2019-09-06 15:15:22 +00:00
|
|
|
},
|
|
|
|
toggleMute () {
|
|
|
|
this.unmuted = !this.unmuted
|
2020-04-25 04:04:39 +00:00
|
|
|
},
|
|
|
|
approveUser () {
|
|
|
|
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
|
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
|
|
|
this.$store.dispatch('updateNotification', {
|
|
|
|
id: this.notification.id,
|
|
|
|
updater: notification => {
|
|
|
|
notification.type = 'follow'
|
2020-05-02 07:19:47 +00:00
|
|
|
notification.seen = true
|
2020-04-25 04:04:39 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
denyUser () {
|
|
|
|
this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
|
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
|
|
|
this.$store.dispatch('dismissNotification', { id: this.notification.id })
|
2018-04-09 17:44:37 +00:00
|
|
|
}
|
2018-06-18 09:09:14 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
userClass () {
|
2019-04-01 01:59:18 +00:00
|
|
|
return highlightClass(this.notification.from_profile)
|
2018-06-18 09:09:14 +00:00
|
|
|
},
|
|
|
|
userStyle () {
|
2019-10-06 20:28:30 +00:00
|
|
|
const highlight = this.$store.getters.mergedConfig.highlight
|
2019-04-01 01:59:18 +00:00
|
|
|
const user = this.notification.from_profile
|
2018-08-05 02:18:04 +00:00
|
|
|
return highlightStyle(highlight[user.screen_name])
|
2019-04-01 14:26:13 +00:00
|
|
|
},
|
|
|
|
user () {
|
2019-12-11 09:48:18 +00:00
|
|
|
return this.$store.getters.findUser(this.notification.from_profile.id)
|
2019-09-06 15:15:22 +00:00
|
|
|
},
|
|
|
|
userProfileLink () {
|
2019-09-10 20:21:52 +00:00
|
|
|
return this.generateUserProfileLink(this.user)
|
2019-09-06 15:15:22 +00:00
|
|
|
},
|
2019-12-10 19:02:25 +00:00
|
|
|
targetUser () {
|
2019-12-11 09:48:18 +00:00
|
|
|
return this.$store.getters.findUser(this.notification.target.id)
|
2019-12-10 19:02:25 +00:00
|
|
|
},
|
|
|
|
targetUserProfileLink () {
|
|
|
|
return this.generateUserProfileLink(this.targetUser)
|
|
|
|
},
|
2019-09-06 15:15:22 +00:00
|
|
|
needMute () {
|
2019-09-10 20:21:52 +00:00
|
|
|
return this.user.muted
|
2020-04-25 04:04:39 +00:00
|
|
|
},
|
|
|
|
isStatusNotification () {
|
|
|
|
return isStatusNotification(this.notification.type)
|
2018-06-19 13:17:50 +00:00
|
|
|
}
|
2018-04-09 17:44:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Notification
|