2020-10-19 22:35:46 +03:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
|
import {
|
|
|
|
|
faCheck,
|
2026-01-06 16:23:17 +02:00
|
|
|
faCompressAlt,
|
|
|
|
|
faExpandAlt,
|
2020-10-19 22:35:46 +03:00
|
|
|
faEyeSlash,
|
2026-01-06 16:23:17 +02:00
|
|
|
faRetweet,
|
|
|
|
|
faStar,
|
2022-12-19 22:20:15 +02:00
|
|
|
faSuitcaseRolling,
|
2026-01-06 16:23:17 +02:00
|
|
|
faTimes,
|
|
|
|
|
faUser,
|
|
|
|
|
faUserPlus,
|
2020-10-19 22:35:46 +03:00
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
2026-01-06 16:23:17 +02:00
|
|
|
import RichContent from 'src/components/rich_content/rich_content.jsx'
|
|
|
|
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
|
import { isStatusNotification } from '../../services/notification_utils/notification_utils.js'
|
|
|
|
|
import {
|
|
|
|
|
highlightClass,
|
|
|
|
|
highlightStyle,
|
|
|
|
|
} from '../../services/user_highlighter/user_highlighter.js'
|
|
|
|
|
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
|
|
|
|
|
import Report from '../report/report.vue'
|
|
|
|
|
import Status from '../status/status.vue'
|
|
|
|
|
import StatusContent from '../status_content/status_content.vue'
|
|
|
|
|
import Timeago from '../timeago/timeago.vue'
|
|
|
|
|
import UserAvatar from '../user_avatar/user_avatar.vue'
|
|
|
|
|
import UserCard from '../user_card/user_card.vue'
|
|
|
|
|
import UserLink from '../user_link/user_link.vue'
|
|
|
|
|
import UserPopover from '../user_popover/user_popover.vue'
|
2020-10-19 22:35:46 +03:00
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
|
faCheck,
|
|
|
|
|
faTimes,
|
|
|
|
|
faStar,
|
|
|
|
|
faRetweet,
|
|
|
|
|
faUserPlus,
|
|
|
|
|
faUser,
|
|
|
|
|
faEyeSlash,
|
2022-12-19 22:20:15 +02:00
|
|
|
faSuitcaseRolling,
|
|
|
|
|
faExpandAlt,
|
2026-01-06 16:22:52 +02:00
|
|
|
faCompressAlt,
|
2020-10-19 22:35:46 +03:00
|
|
|
)
|
2018-04-09 20:44:37 +03:00
|
|
|
|
|
|
|
|
const Notification = {
|
2026-01-06 16:22:52 +02:00
|
|
|
data() {
|
2018-04-09 20:44:37 +03:00
|
|
|
return {
|
2025-08-19 17:28:19 +03:00
|
|
|
selecting: false,
|
2022-12-19 22:20:15 +02:00
|
|
|
statusExpanded: false,
|
2022-06-07 12:37:16 -04:00
|
|
|
unmuted: false,
|
|
|
|
|
showingApproveConfirmDialog: false,
|
2026-01-06 16:22:52 +02:00
|
|
|
showingDenyConfirmDialog: false,
|
2018-04-09 20:44:37 +03:00
|
|
|
}
|
|
|
|
|
},
|
2022-07-31 12:35:48 +03:00
|
|
|
props: ['notification'],
|
2023-11-13 17:29:25 +02:00
|
|
|
emits: ['interacted'],
|
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,
|
2022-06-15 04:01:46 +03:00
|
|
|
RichContent,
|
2022-08-29 18:46:41 -04:00
|
|
|
UserPopover,
|
2022-06-07 12:37:16 -04:00
|
|
|
UserLink,
|
2026-01-06 16:22:52 +02:00
|
|
|
ConfirmModal,
|
2018-04-09 20:44:37 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
mounted() {
|
2025-08-19 17:28:19 +03:00
|
|
|
document.addEventListener('selectionchange', this.onContentSelect)
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
unmounted() {
|
2025-08-19 17:28:19 +03:00
|
|
|
document.removeEventListener('selectionchange', this.onContentSelect)
|
|
|
|
|
},
|
2018-04-09 20:44:37 +03:00
|
|
|
methods: {
|
2026-01-06 16:22:52 +02:00
|
|
|
toggleStatusExpanded() {
|
2025-08-14 12:53:19 +03:00
|
|
|
if (!this.expandable) return
|
2022-12-19 22:20:15 +02:00
|
|
|
this.statusExpanded = !this.statusExpanded
|
2018-12-17 02:52:27 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
onContentSelect() {
|
2025-08-19 17:28:19 +03:00
|
|
|
const { isCollapsed, anchorNode, offsetNode } = document.getSelection()
|
|
|
|
|
if (isCollapsed) {
|
|
|
|
|
this.selecting = false
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-01-06 16:22:52 +02:00
|
|
|
const within =
|
|
|
|
|
this.$refs.root.contains(anchorNode) ||
|
|
|
|
|
this.$refs.root.contains(offsetNode)
|
2025-08-19 17:28:19 +03:00
|
|
|
if (within) {
|
|
|
|
|
this.selecting = true
|
|
|
|
|
} else {
|
|
|
|
|
this.selecting = false
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
onContentClick(e) {
|
|
|
|
|
if (
|
|
|
|
|
!this.selecting &&
|
|
|
|
|
!e.target.closest('a') &&
|
|
|
|
|
!e.target.closest('button')
|
|
|
|
|
) {
|
2025-08-19 17:28:19 +03:00
|
|
|
this.toggleStatusExpanded()
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
generateUserProfileLink(user) {
|
|
|
|
|
return generateProfileLink(
|
|
|
|
|
user.id,
|
|
|
|
|
user.screen_name,
|
|
|
|
|
this.$store.state.instance.restrictedNicknames,
|
|
|
|
|
)
|
2019-02-18 17:49:32 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02: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
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
interacted() {
|
2023-11-13 17:29:25 +02:00
|
|
|
this.$emit('interacted')
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
toggleMute() {
|
2019-09-06 11:15:22 -04:00
|
|
|
this.unmuted = !this.unmuted
|
2020-04-25 07:04:39 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
showApproveConfirmDialog() {
|
2022-06-07 12:37:16 -04:00
|
|
|
this.showingApproveConfirmDialog = true
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
hideApproveConfirmDialog() {
|
2022-06-07 12:37:16 -04:00
|
|
|
this.showingApproveConfirmDialog = false
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
showDenyConfirmDialog() {
|
2022-06-07 12:37:16 -04:00
|
|
|
this.showingDenyConfirmDialog = true
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
hideDenyConfirmDialog() {
|
2022-06-07 12:37:16 -04:00
|
|
|
this.showingDenyConfirmDialog = false
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
approveUser() {
|
2022-06-07 12:37:16 -04:00
|
|
|
if (this.shouldConfirmApprove) {
|
|
|
|
|
this.showApproveConfirmDialog()
|
|
|
|
|
} else {
|
|
|
|
|
this.doApprove()
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
doApprove() {
|
2023-11-13 17:29:25 +02:00
|
|
|
this.$emit('interacted')
|
2020-04-25 07:04:39 +03:00
|
|
|
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
|
|
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
2026-01-06 16:22:52 +02: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,
|
2026-01-06 16:22:52 +02:00
|
|
|
updater: (notification) => {
|
2020-04-25 07:04:39 +03:00
|
|
|
notification.type = 'follow'
|
2026-01-06 16:22:52 +02:00
|
|
|
},
|
2020-04-25 07:04:39 +03:00
|
|
|
})
|
2022-06-10 15:55:31 -04:00
|
|
|
this.hideApproveConfirmDialog()
|
2020-04-25 07:04:39 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
denyUser() {
|
2022-06-07 12:37:16 -04:00
|
|
|
if (this.shouldConfirmDeny) {
|
|
|
|
|
this.showDenyConfirmDialog()
|
|
|
|
|
} else {
|
|
|
|
|
this.doDeny()
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
doDeny() {
|
2023-11-13 17:29:25 +02:00
|
|
|
this.$emit('interacted')
|
2026-01-06 16:22:52 +02:00
|
|
|
this.$store.state.api.backendInteractor
|
|
|
|
|
.denyUser({ id: this.user.id })
|
2020-05-02 11:51:39 +03:00
|
|
|
.then(() => {
|
2026-01-06 16:22:52 +02:00
|
|
|
this.$store.dispatch('dismissNotificationLocal', {
|
|
|
|
|
id: this.notification.id,
|
|
|
|
|
})
|
2020-05-02 11:51:39 +03:00
|
|
|
this.$store.dispatch('removeFollowRequest', this.user)
|
|
|
|
|
})
|
2022-06-10 15:55:31 -04:00
|
|
|
this.hideDenyConfirmDialog()
|
2026-01-06 16:22:52 +02:00
|
|
|
},
|
2018-06-18 12:09:14 +03:00
|
|
|
},
|
|
|
|
|
computed: {
|
2026-01-06 16:22:52 +02:00
|
|
|
userClass() {
|
2019-03-31 21:59:18 -04:00
|
|
|
return highlightClass(this.notification.from_profile)
|
2018-06-18 12:09:14 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02: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
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
expandable() {
|
|
|
|
|
return new Set(['like', 'pleroma:emoji_reaction', 'repeat', 'poll']).has(
|
|
|
|
|
this.notification.type,
|
|
|
|
|
)
|
2025-08-14 12:53:19 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02: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
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
userProfileLink() {
|
2019-09-10 16:21:52 -04:00
|
|
|
return this.generateUserProfileLink(this.user)
|
2019-09-06 11:15:22 -04:00
|
|
|
},
|
2026-01-06 16:22:52 +02: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
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
targetUserProfileLink() {
|
2019-12-11 04:02:25 +09:00
|
|
|
return this.generateUserProfileLink(this.targetUser)
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02: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
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
isStatusNotification() {
|
2020-04-25 07:04:39 +03:00
|
|
|
return isStatusNotification(this.notification.type)
|
2020-05-07 16:10:53 +03:00
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
mergedConfig() {
|
2022-06-07 12:37:16 -04:00
|
|
|
return this.$store.getters.mergedConfig
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
shouldConfirmApprove() {
|
2022-06-07 12:37:16 -04:00
|
|
|
return this.mergedConfig.modalOnApproveFollow
|
|
|
|
|
},
|
2026-01-06 16:22:52 +02:00
|
|
|
shouldConfirmDeny() {
|
2022-06-07 12:37:16 -04:00
|
|
|
return this.mergedConfig.modalOnDenyFollow
|
|
|
|
|
},
|
2020-05-07 16:10:53 +03:00
|
|
|
...mapState({
|
2026-01-06 16:22:52 +02:00
|
|
|
currentUser: (state) => state.users.currentUser,
|
|
|
|
|
}),
|
|
|
|
|
},
|
2018-04-09 20:44:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Notification
|