2020-05-26 01:01:25 +03:00
|
|
|
import StatusContent from '../status_content/status_content.vue'
|
2020-05-07 16:10:53 +03:00
|
|
|
import { mapState } from 'vuex'
|
2018-04-09 20:44:37 +03:00
|
|
|
import Status from '../status/status.vue'
|
2019-02-02 15:33:02 -05:00
|
|
|
import UserAvatar from '../user_avatar/user_avatar.vue'
|
2019-03-05 14:01:49 -05:00
|
|
|
import UserCard from '../user_card/user_card.vue'
|
2019-06-18 20:28:31 +00:00
|
|
|
import Timeago from '../timeago/timeago.vue'
|
2021-01-11 19:32:58 +02:00
|
|
|
import Report from '../report/report.vue'
|
2021-08-13 13:06:42 +03:00
|
|
|
import RichContent from 'src/components/rich_content/rich_content.jsx'
|
2020-04-25 07:04:39 +03:00
|
|
|
import { isStatusNotification } from '../../services/notification_utils/notification_utils.js'
|
2018-06-18 12:09:14 +03:00
|
|
|
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
|
2018-12-13 19:57:11 +03:00
|
|
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
2020-10-19 22:35:46 +03:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
|
|
|
faCheck,
|
|
|
|
faTimes,
|
|
|
|
faStar,
|
|
|
|
faRetweet,
|
|
|
|
faUserPlus,
|
|
|
|
faEyeSlash,
|
|
|
|
faUser,
|
|
|
|
faSuitcaseRolling
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faCheck,
|
|
|
|
faTimes,
|
|
|
|
faStar,
|
|
|
|
faRetweet,
|
|
|
|
faUserPlus,
|
|
|
|
faUser,
|
|
|
|
faEyeSlash,
|
|
|
|
faSuitcaseRolling
|
|
|
|
)
|
2018-04-09 20:44:37 +03:00
|
|
|
|
|
|
|
const Notification = {
|
|
|
|
data () {
|
|
|
|
return {
|
2018-11-30 16:39:07 +03:00
|
|
|
userExpanded: false,
|
2019-09-06 11:15:22 -04:00
|
|
|
betterShadow: this.$store.state.interface.browserSupport.cssFilter,
|
|
|
|
unmuted: false
|
2018-04-09 20:44:37 +03:00
|
|
|
}
|
|
|
|
},
|
2018-12-28 21:39:54 +02:00
|
|
|
props: [ 'notification' ],
|
2018-04-09 20:44:37 +03:00
|
|
|
components: {
|
2020-05-26 01:01:25 +03:00
|
|
|
StatusContent,
|
2019-06-18 20:28:31 +00:00
|
|
|
UserAvatar,
|
|
|
|
UserCard,
|
2020-05-26 01:01:25 +03:00
|
|
|
Timeago,
|
2021-01-11 19:32:58 +02:00
|
|
|
Status,
|
2022-02-26 02:08:13 +01:00
|
|
|
Report,
|
2021-08-13 13:06:42 +03:00
|
|
|
RichContent
|
2018-04-09 20:44:37 +03:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleUserExpanded () {
|
|
|
|
this.userExpanded = !this.userExpanded
|
2018-12-17 02:52:27 +03:00
|
|
|
},
|
2019-09-06 11:15:22 -04:00
|
|
|
generateUserProfileLink (user) {
|
2018-12-26 14:50:48 +01:00
|
|
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
2019-02-18 17:49:32 +03:00
|
|
|
},
|
|
|
|
getUser (notification) {
|
2019-04-12 10:49:22 +03:00
|
|
|
return this.$store.state.users.usersObject[notification.from_profile.id]
|
2019-09-06 11:15:22 -04:00
|
|
|
},
|
|
|
|
toggleMute () {
|
|
|
|
this.unmuted = !this.unmuted
|
2020-04-25 07:04:39 +03:00
|
|
|
},
|
|
|
|
approveUser () {
|
|
|
|
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
|
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
2020-05-02 10:52:57 +03:00
|
|
|
this.$store.dispatch('markSingleNotificationAsSeen', { id: this.notification.id })
|
2020-04-25 07:04:39 +03:00
|
|
|
this.$store.dispatch('updateNotification', {
|
|
|
|
id: this.notification.id,
|
|
|
|
updater: notification => {
|
|
|
|
notification.type = 'follow'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
denyUser () {
|
|
|
|
this.$store.state.api.backendInteractor.denyUser({ id: this.user.id })
|
2020-05-02 11:51:39 +03:00
|
|
|
.then(() => {
|
|
|
|
this.$store.dispatch('dismissNotificationLocal', { id: this.notification.id })
|
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
|
|
|
})
|
2018-04-09 20:44:37 +03:00
|
|
|
}
|
2018-06-18 12:09:14 +03:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
userClass () {
|
2019-03-31 21:59:18 -04:00
|
|
|
return highlightClass(this.notification.from_profile)
|
2018-06-18 12:09:14 +03:00
|
|
|
},
|
|
|
|
userStyle () {
|
2019-10-06 23:28:30 +03:00
|
|
|
const highlight = this.$store.getters.mergedConfig.highlight
|
2019-03-31 21:59:18 -04:00
|
|
|
const user = this.notification.from_profile
|
2018-08-05 05:18:04 +03:00
|
|
|
return highlightStyle(highlight[user.screen_name])
|
2019-04-01 07:26:13 -07:00
|
|
|
},
|
|
|
|
user () {
|
2019-12-11 18:48:18 +09:00
|
|
|
return this.$store.getters.findUser(this.notification.from_profile.id)
|
2019-09-06 11:15:22 -04:00
|
|
|
},
|
|
|
|
userProfileLink () {
|
2019-09-10 16:21:52 -04:00
|
|
|
return this.generateUserProfileLink(this.user)
|
2019-09-06 11:15:22 -04:00
|
|
|
},
|
2019-12-11 04:02:25 +09:00
|
|
|
targetUser () {
|
2019-12-11 18:48:18 +09:00
|
|
|
return this.$store.getters.findUser(this.notification.target.id)
|
2019-12-11 04:02:25 +09:00
|
|
|
},
|
|
|
|
targetUserProfileLink () {
|
|
|
|
return this.generateUserProfileLink(this.targetUser)
|
|
|
|
},
|
2019-09-06 11:15:22 -04:00
|
|
|
needMute () {
|
2020-04-24 18:53:17 +03:00
|
|
|
return this.$store.getters.relationship(this.user.id).muting
|
2020-04-25 07:04:39 +03:00
|
|
|
},
|
|
|
|
isStatusNotification () {
|
|
|
|
return isStatusNotification(this.notification.type)
|
2020-05-07 16:10:53 +03:00
|
|
|
},
|
|
|
|
...mapState({
|
|
|
|
currentUser: state => state.users.currentUser
|
|
|
|
})
|
2018-04-09 20:44:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Notification
|