pleroma-fe/src/components/status/status.js

675 lines
20 KiB
JavaScript
Raw Normal View History

2026-01-06 17:32:22 +02:00
import { unescape as ldUnescape, uniqBy } from 'lodash'
2026-01-08 17:26:52 +02:00
2026-01-06 16:23:17 +02:00
import MentionLink from 'src/components/mention_link/mention_link.vue'
import MentionsLine from 'src/components/mentions_line/mentions_line.vue'
import RichContent from 'src/components/rich_content/rich_content.jsx'
import StatusActionButtons from 'src/components/status_action_buttons/status_action_buttons.vue'
import { muteFilterHits } from '../../services/status_parser/status_parser.js'
import {
highlightClass,
highlightStyle,
} from '../../services/user_highlighter/user_highlighter.js'
import AvatarList from '../avatar_list/avatar_list.vue'
import EmojiReactions from '../emoji_reactions/emoji_reactions.vue'
import PostStatusForm from '../post_status_form/post_status_form.vue'
import StatusContent from '../status_content/status_content.vue'
import StatusPopover from '../status_popover/status_popover.vue'
import Timeago from '../timeago/timeago.vue'
import UserAvatar from '../user_avatar/user_avatar.vue'
import UserLink from '../user_link/user_link.vue'
import UserListPopover from '../user_list_popover/user_list_popover.vue'
import UserPopover from '../user_popover/user_popover.vue'
2026-01-29 20:40:00 +02:00
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
2026-02-13 13:59:00 +02:00
import { useSyncConfigStore } from 'src/stores/sync_config.js'
2026-03-06 15:21:30 +02:00
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
2026-01-29 20:40:00 +02:00
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
2026-01-08 17:26:52 +02:00
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faAngleDoubleRight,
faChevronDown,
faChevronUp,
faEllipsisH,
faEnvelope,
faEye,
faEyeSlash,
faGlobe,
faIgloo,
faLock,
faLockOpen,
faPlay,
faPlusSquare,
faReply,
faRetweet,
faSmileBeam,
faStar,
faThumbtack,
faTimes,
} from '@fortawesome/free-solid-svg-icons'
library.add(
faEnvelope,
2020-10-21 00:25:59 +03:00
faGlobe,
faIgloo,
faLock,
faLockOpen,
faTimes,
faRetweet,
faReply,
faPlusSquare,
faStar,
faSmileBeam,
faEllipsisH,
faEyeSlash,
faEye,
2021-08-07 00:33:06 -04:00
faThumbtack,
faChevronUp,
faChevronDown,
faAngleDoubleRight,
2026-01-06 16:22:52 +02:00
faPlay,
)
2026-01-06 16:22:52 +02:00
const camelCase = (name) => name.charAt(0).toUpperCase() + name.slice(1)
2026-01-06 16:22:52 +02:00
const controlledOrUncontrolledGetters = (list) =>
list.reduce((res, name) => {
const camelized = camelCase(name)
const toggle = `controlledToggle${camelized}`
const controlledName = `controlled${camelized}`
const uncontrolledName = `uncontrolled${camelized}`
res[name] = function () {
return (this.$data[toggle] !== undefined ||
this.$props[toggle] !== undefined) &&
this[toggle]
? this[controlledName]
: this[uncontrolledName]
}
return res
}, {})
const controlledOrUncontrolledToggle = (obj, name) => {
const camelized = camelCase(name)
const toggle = `controlledToggle${camelized}`
const uncontrolledName = `uncontrolled${camelized}`
if (obj[toggle]) {
obj[toggle]()
} else {
obj[uncontrolledName] = !obj[uncontrolledName]
}
}
const controlledOrUncontrolledSet = (obj, name, val) => {
const camelized = camelCase(name)
const set = `controlledSet${camelized}`
const uncontrolledName = `uncontrolled${camelized}`
if (obj[set]) {
obj[set](val)
} else {
obj[uncontrolledName] = val
}
}
2016-10-28 15:19:42 +02:00
const Status = {
2018-04-09 19:43:31 +03:00
name: 'Status',
components: {
PostStatusForm,
UserAvatar,
AvatarList,
Timeago,
StatusPopover,
UserListPopover,
EmojiReactions,
StatusContent,
2021-06-08 11:38:44 +03:00
RichContent,
MentionLink,
2022-06-13 13:45:04 +03:00
MentionsLine,
UserPopover,
2025-01-09 17:43:48 +02:00
UserLink,
2026-01-06 16:22:52 +02:00
StatusActionButtons,
},
props: [
'statusoid',
2026-02-15 21:31:52 +02:00
'replies',
'expandable',
'focused',
'highlight',
'compact',
'isPreview',
2018-04-09 19:43:31 +03:00
'noHeading',
'inlineExpanded',
'showPinned',
'inProfile',
2026-02-15 21:31:52 +02:00
'inConversation',
2023-07-13 00:37:57 -04:00
'inQuote',
2026-02-15 21:31:52 +02:00
'profileUserId',
2021-08-07 18:53:23 -04:00
'simpleTree',
'showOtherRepliesAsButton',
2026-02-15 21:31:52 +02:00
'dive',
2021-08-07 10:28:45 -04:00
2026-02-15 21:31:52 +02:00
'controlledThreadDisplayStatus',
'controlledToggleThreadDisplay',
2021-08-07 10:28:45 -04:00
'controlledShowingTall',
'controlledToggleShowingTall',
'controlledExpandingSubject',
'controlledToggleExpandingSubject',
'controlledShowingLongSubject',
'controlledToggleShowingLongSubject',
'controlledReplying',
'controlledToggleReplying',
'controlledMediaPlaying',
'controlledSetMediaPlaying',
],
2026-02-15 21:31:52 +02:00
emits: ['interacted', 'goto', 'toggleExpanded'],
2026-01-06 16:22:52 +02:00
data() {
return {
uncontrolledReplying: false,
unmuted: false,
userExpanded: false,
uncontrolledMediaPlaying: [],
2020-09-29 10:18:37 +00:00
suspendable: true,
error: null,
2023-07-13 00:37:57 -04:00
headTailLinks: null,
2026-01-06 16:22:52 +02:00
displayQuote: !this.inQuote,
}
},
2016-10-28 18:08:03 +02:00
computed: {
...controlledOrUncontrolledGetters(['replying', 'mediaPlaying']),
2026-01-06 16:22:52 +02:00
showReasonMutedThread() {
return (
2026-01-06 16:22:52 +02:00
(this.status.thread_muted ||
(this.status.reblog && this.status.reblog.thread_muted)) &&
!this.inConversation
)
},
2026-01-06 16:22:52 +02:00
repeaterClass() {
2018-06-18 11:36:58 +03:00
const user = this.statusoid.user
return highlightClass(user)
2018-06-18 11:36:58 +03:00
},
2026-01-06 16:22:52 +02:00
userClass() {
const user = this.retweet
? this.statusoid.retweeted_status.user
: this.statusoid.user
return highlightClass(user)
2018-06-18 11:36:58 +03:00
},
2026-01-06 16:22:52 +02:00
deleted() {
return this.statusoid.deleted
},
2026-01-06 16:22:52 +02:00
repeaterStyle() {
2018-06-18 11:36:58 +03:00
const user = this.statusoid.user
2026-03-06 15:21:30 +02:00
return highlightStyle(useUserHighlightStore().get(user.screen_name))
2018-06-18 11:36:58 +03:00
},
2026-01-06 16:22:52 +02:00
userStyle() {
if (this.noHeading) return
2026-01-06 16:22:52 +02:00
const user = this.retweet
? this.statusoid.retweeted_status.user
: this.statusoid.user
2026-03-06 15:21:30 +02:00
return highlightStyle(useUserHighlightStore().get(user.screen_name))
2018-04-25 17:35:25 +03:00
},
2026-01-06 16:22:52 +02:00
userProfileLink() {
return this.generateUserProfileLink(
this.status.user.id,
this.status.user.screen_name,
)
},
2026-01-06 16:22:52 +02:00
replyProfileLink() {
if (this.isReply) {
2026-01-06 16:22:52 +02:00
const user = this.$store.getters.findUser(
this.status.in_reply_to_user_id,
)
// FIXME Why user not found sometimes???
return user ? user.statusnet_profile_url : 'NOT_FOUND'
}
},
2026-01-06 16:22:52 +02:00
retweet() {
return !!this.statusoid.retweeted_status
},
retweeterUser() {
return this.statusoid.user
},
retweeter() {
return this.statusoid.user.name || this.statusoid.user.screen_name_ui
},
retweeterHtml() {
return this.statusoid.user.name
},
retweeterProfileLink() {
return this.generateUserProfileLink(
this.statusoid.user.id,
this.statusoid.user.screen_name,
)
},
status() {
2016-10-28 18:08:03 +02:00
if (this.retweet) {
return this.statusoid.retweeted_status
} else {
return this.statusoid
}
2016-11-06 20:45:26 +01:00
},
2026-01-06 16:22:52 +02:00
statusFromGlobalRepository() {
// NOTE: Consider to replace status with statusFromGlobalRepository
return this.$store.state.statuses.allStatusesObject[this.status.id]
},
2026-01-06 16:22:52 +02:00
loggedIn() {
2019-11-14 00:18:14 +02:00
return !!this.currentUser
2017-02-14 00:01:50 +01:00
},
2026-01-06 16:22:52 +02:00
muteFilterHits() {
return muteFilterHits(
2026-02-13 13:59:00 +02:00
Object.values(useSyncConfigStore().prefsStorage.simple.muteFilters),
2026-01-06 16:22:52 +02:00
this.status,
)
},
2026-01-06 16:22:52 +02:00
botStatus() {
return this.status.user.actor_type === 'Service'
2022-02-28 23:07:20 +03:00
},
2026-01-06 16:22:52 +02:00
showActorTypeIndicator() {
2023-12-27 22:54:44 -05:00
return !this.hideBotIndication
},
2026-01-06 16:22:52 +02:00
sensitiveStatus() {
return this.status.nsfw
},
2026-01-06 16:22:52 +02:00
mentionsLine() {
2021-08-14 21:55:38 +03:00
if (!this.headTailLinks) return []
2026-01-06 16:22:52 +02:00
const writtenSet = new Set(
this.headTailLinks.writtenMentions.map((_) => _.url),
)
return this.status.attentions
.filter((attn) => {
// no reply user
return (
attn.id !== this.status.in_reply_to_user_id &&
// no self-replies
attn.statusnet_profile_url !==
this.status.user.statusnet_profile_url &&
// don't include if mentions is written
!writtenSet.has(attn.statusnet_profile_url)
)
})
.map((attn) => ({
url: attn.statusnet_profile_url,
content: attn.screen_name,
userId: attn.id,
}))
},
hasMentionsLine() {
return this.mentionsLine.length > 0
2021-06-08 11:38:44 +03:00
},
2026-01-06 16:22:52 +02:00
muteReasons() {
return [
this.userIsMuted ? 'user' : null,
this.status.thread_muted ? 'thread' : null,
2026-01-06 16:22:52 +02:00
this.muteFilterHits.length > 0 ? 'filtered' : null,
this.muteBotStatuses && this.botStatus ? 'bot' : null,
this.muteSensitiveStatuses && this.sensitiveStatus ? 'nsfw' : null,
].filter((_) => _)
},
2026-01-06 16:22:52 +02:00
muteLocalized() {
if (this.muteReasons.length === 0) return null
const mainReason = () => {
switch (this.muteReasons[0]) {
2026-01-06 16:22:52 +02:00
case 'user':
return this.$t('status.muted_user')
case 'thread':
return this.$t('status.thread_muted')
2025-03-25 19:48:12 +02:00
case 'filtered':
return this.$t(
2025-03-25 19:48:12 +02:00
'status.muted_filters',
{
2025-03-25 19:48:12 +02:00
name: this.muteFilterHits[0].name,
2026-01-06 16:22:52 +02:00
filterMore: this.muteFilterHits.length - 1,
},
2026-01-06 16:22:52 +02:00
this.muteFilterHits.length,
)
2026-01-06 16:22:52 +02:00
case 'bot':
return this.$t('status.bot_muted')
case 'nsfw':
return this.$t('status.sensitive_muted')
}
}
if (this.muteReasons.length > 1) {
return this.$t(
'status.multi_reason_mute',
{
main: mainReason(),
2026-01-06 16:22:52 +02:00
numReasonsMore: this.muteReasons.length - 1,
},
2026-01-06 16:22:52 +02:00
this.muteReasons.length - 1,
)
} else {
return mainReason()
}
},
2026-01-06 16:22:52 +02:00
muted() {
if (this.statusoid.user.id === this.currentUser.id) return false
return !this.unmuted && !this.shouldNotMute && this.muteReasons.length > 0
},
2026-01-06 16:22:52 +02:00
userIsMuted() {
2021-01-11 19:40:35 +02:00
if (this.statusoid.user.id === this.currentUser.id) return false
const { status } = this
const { reblog } = status
const relationship = this.$store.getters.relationship(status.user.id)
2026-01-06 16:22:52 +02:00
const relationshipReblog =
reblog && this.$store.getters.relationship(reblog.user.id)
return (
(status.muted && !status.thread_muted) ||
// Reprööt of a muted post according to BE
(reblog && reblog.muted && !reblog.thread_muted) ||
// Muted user
relationship.muting ||
// Muted user of a reprööt
(relationshipReblog && relationshipReblog.muting)
2026-01-06 16:22:52 +02:00
)
},
2026-01-06 16:22:52 +02:00
shouldNotMute() {
2025-05-13 17:53:32 +03:00
if (this.isFocused) return true
const { status } = this
const { reblog } = status
return (
2026-01-06 16:22:52 +02:00
((this.inProfile &&
// Don't mute user's posts on user timeline (except reblogs)
((!reblog && status.user.id === this.profileUserId) ||
// Same as above but also allow self-reblogs
2026-01-06 16:22:52 +02:00
(reblog && reblog.user.id === this.profileUserId))) ||
// Don't mute statuses in muted conversation when said conversation is opened
(this.inConversation && status.thread_muted)) &&
// No excuses if post has muted words
2026-01-06 16:22:52 +02:00
!this.muteFilterHits.length > 0
)
},
2026-01-06 16:22:52 +02:00
hideMutedUsers() {
return this.mergedConfig.hideMutedPosts
},
2026-01-06 16:22:52 +02:00
hideMutedThreads() {
return this.mergedConfig.hideMutedThreads
2020-04-21 23:27:51 +03:00
},
2026-01-06 16:22:52 +02:00
hideFilteredStatuses() {
return this.mergedConfig.hideFilteredStatuses
2019-02-06 10:18:13 -08:00
},
2026-01-06 16:22:52 +02:00
hideWordFilteredPosts() {
return this.mergedConfig.hideWordFilteredPosts
},
2026-01-06 16:22:52 +02:00
hideStatus() {
return (
!this.shouldNotMute &&
((this.muted && this.hideFilteredStatuses) ||
(this.userIsMuted && this.hideMutedUsers) ||
(this.status.thread_muted && this.hideMutedThreads) ||
(this.muteFilterHits.length > 0 && this.hideWordFilteredPosts) ||
this.muteFilterHits.some((x) => x.hide))
)
2019-02-08 04:25:56 -08:00
},
2026-01-06 16:22:52 +02:00
isFocused() {
// retweet or root of an expanded conversation
2017-04-12 19:07:55 +03:00
if (this.focused) {
return true
2017-04-12 19:07:55 +03:00
} else if (!this.inConversation) {
return false
2017-04-12 19:07:55 +03:00
}
// use conversation highlight only when in conversation
return this.status.id === this.highlight
2018-04-09 19:43:31 +03:00
},
2026-01-06 16:22:52 +02:00
isReply() {
return !!(
this.status.in_reply_to_status_id && this.status.in_reply_to_user_id
)
},
2026-01-06 16:22:52 +02:00
replyToName() {
if (this.status.in_reply_to_screen_name) {
2019-01-24 20:27:20 +03:00
return this.status.in_reply_to_screen_name
} else {
2026-01-06 16:22:52 +02:00
const user = this.$store.getters.findUser(
this.status.in_reply_to_user_id,
)
return user && user.screen_name_ui
}
},
2026-01-06 16:22:52 +02:00
replySubject() {
2018-09-25 15:21:47 +03:00
if (!this.status.summary) return ''
2026-01-06 17:32:22 +02:00
const decodedSummary = ldUnescape(this.status.summary)
const behavior = this.mergedConfig.subjectLineBehavior
2019-02-08 08:25:53 -08:00
const startsWithRe = decodedSummary.match(/^re[: ]/i)
2019-07-07 00:54:17 +03:00
if ((behavior !== 'noop' && startsWithRe) || behavior === 'masto') {
2019-02-08 08:25:53 -08:00
return decodedSummary
2018-09-25 15:16:26 +03:00
} else if (behavior === 'email') {
2019-02-08 08:25:53 -08:00
return 're: '.concat(decodedSummary)
2018-09-25 15:16:26 +03:00
} else if (behavior === 'noop') {
return ''
2018-08-26 01:50:11 +01:00
}
},
2026-01-06 16:22:52 +02:00
combinedFavsAndRepeatsUsers() {
// Use the status from the global status repository since favs and repeats are saved in it
const combinedUsers = [].concat(
2019-04-29 22:36:39 +03:00
this.statusFromGlobalRepository.favoritedBy,
2026-01-06 16:22:52 +02:00
this.statusFromGlobalRepository.rebloggedBy,
2019-04-29 22:36:39 +03:00
)
return uniqBy(combinedUsers, 'id')
2019-04-04 12:56:13 -04:00
},
2026-01-06 16:22:52 +02:00
tags() {
return this.status.tags
.filter((tagObj) => Object.hasOwn(tagObj, 'name'))
.map((tagObj) => tagObj.name)
.join(' ')
},
2026-01-06 16:22:52 +02:00
hidePostStats() {
return this.mergedConfig.hidePostStats
},
2026-01-06 16:22:52 +02:00
shouldDisplayFavsAndRepeats() {
return (
!this.hidePostStats &&
this.isFocused &&
(this.combinedFavsAndRepeatsUsers.length > 0 ||
this.statusFromGlobalRepository.quotes_count)
)
},
2026-01-06 16:22:52 +02:00
muteBotStatuses() {
2022-02-28 23:07:20 +03:00
return this.mergedConfig.muteBotStatuses
},
2026-01-06 16:22:52 +02:00
muteSensitiveStatuses() {
return this.mergedConfig.muteSensitiveStatuses
},
2026-01-06 16:22:52 +02:00
hideBotIndication() {
return this.mergedConfig.hideBotIndication
},
2026-01-06 16:22:52 +02:00
currentUser() {
2020-09-29 10:18:37 +00:00
return this.$store.state.users.currentUser
},
2026-01-06 16:22:52 +02:00
mergedConfig() {
return useMergedConfigStore().mergedConfig
2020-09-29 10:18:37 +00:00
},
2026-01-06 16:22:52 +02:00
isSuspendable() {
2020-09-29 10:18:37 +00:00
return !this.replying && this.mediaPlaying.length === 0
2021-08-07 00:33:06 -04:00
},
2026-01-06 16:22:52 +02:00
inThreadForest() {
2021-08-07 00:33:06 -04:00
return !!this.controlledThreadDisplayStatus
},
2026-01-06 16:22:52 +02:00
threadShowing() {
2021-08-07 00:33:06 -04:00
return this.controlledThreadDisplayStatus === 'showing'
},
2026-01-06 16:22:52 +02:00
visibilityLocalized() {
return this.$i18n.t('general.scope_in_timeline.' + this.status.visibility)
2022-06-22 16:05:27 -04:00
},
2026-01-06 16:22:52 +02:00
isEdited() {
2022-06-22 16:05:27 -04:00
return this.status.edited_at !== null
},
2026-01-06 16:22:52 +02:00
editingAvailable() {
return useInstanceCapabilitiesStore().editingAvailable
2023-07-12 20:45:44 -04:00
},
2026-01-06 16:22:52 +02:00
hasVisibleQuote() {
2023-07-13 00:37:57 -04:00
return this.status.quote_url && this.status.quote_visible
},
2026-01-06 16:22:52 +02:00
hasInvisibleQuote() {
2023-07-13 00:37:57 -04:00
return this.status.quote_url && !this.status.quote_visible
},
2026-01-06 16:22:52 +02:00
quotedStatus() {
return this.status.quote_id
? this.$store.state.statuses.allStatusesObject[this.status.quote_id]
: undefined
2023-07-13 00:37:57 -04:00
},
2026-01-06 16:22:52 +02:00
shouldDisplayQuote() {
2023-07-13 00:37:57 -04:00
return this.quotedStatus && this.displayQuote
},
2026-01-06 16:22:52 +02:00
scrobblePresent() {
2024-03-25 23:34:19 +02:00
if (this.mergedConfig.hideScrobbles) return false
2025-10-07 06:48:17 +00:00
if (!this.status.user?.latestScrobble) return false
2024-03-25 23:34:19 +02:00
const value = this.mergedConfig.hideScrobblesAfter.match(/\d+/gs)[0]
const unit = this.mergedConfig.hideScrobblesAfter.match(/\D+/gs)[0]
let multiplier = 60 * 1000 // minutes is smallest unit
switch (unit) {
case 'm':
break
case 'h':
2024-03-25 23:34:19 +02:00
multiplier *= 60 // hour
break
case 'd':
multiplier *= 60 // hour
multiplier *= 24 // day
break
}
const maxAge = Number(value) * multiplier
const createdAt = Date.parse(this.status.user.latestScrobble.created_at)
const age = Date.now() - createdAt
if (age > maxAge) return false
return this.status.user.latestScrobble.artist
},
2026-01-06 16:22:52 +02:00
scrobble() {
2025-10-07 06:48:17 +00:00
return this.status.user?.latestScrobble
2026-01-06 16:22:52 +02:00
},
2016-10-28 18:08:03 +02:00
},
2016-11-03 16:59:27 +01:00
methods: {
2026-01-06 16:22:52 +02:00
visibilityIcon(visibility) {
2018-05-21 23:01:33 +01:00
switch (visibility) {
case 'private':
return 'lock'
2018-05-21 23:01:33 +01:00
case 'unlisted':
return 'lock-open'
2018-05-21 23:01:33 +01:00
case 'direct':
return 'envelope'
case 'local':
return 'igloo'
2018-05-21 23:01:33 +01:00
default:
2020-10-21 00:25:59 +03:00
return 'globe'
2018-05-20 18:28:01 +02:00
}
},
2026-01-06 16:22:52 +02:00
showError(error) {
this.error = error
2019-04-27 09:36:10 -04:00
},
2026-01-06 16:22:52 +02:00
clearError() {
this.$emit('interacted')
2019-04-27 09:36:10 -04:00
this.error = undefined
},
2026-01-06 16:22:52 +02:00
toggleReplying() {
this.$emit('interacted')
if (this.replying) {
this.$refs.postStatusForm.requestClose()
} else {
this.doToggleReplying()
}
},
2026-01-06 16:22:52 +02:00
doToggleReplying() {
controlledOrUncontrolledToggle(this, 'replying')
},
2026-01-06 16:22:52 +02:00
gotoOriginal(id) {
if (this.inConversation) {
this.$emit('goto', id)
}
},
2026-01-06 16:22:52 +02:00
toggleExpanded() {
this.$emit('toggleExpanded')
2017-02-14 00:01:50 +01:00
},
2026-01-06 16:22:52 +02:00
toggleMute() {
2017-02-14 00:01:50 +01:00
this.unmuted = !this.unmuted
2017-02-16 15:58:49 +01:00
},
2026-01-06 16:22:52 +02:00
toggleUserExpanded() {
2017-02-16 15:58:49 +01:00
this.userExpanded = !this.userExpanded
},
2026-01-06 16:22:52 +02:00
generateUserProfileLink(id, name) {
return generateProfileLink(
id,
name,
useInstanceStore().restrictedNicknames,
2026-01-06 16:22:52 +02:00
)
2020-09-29 10:18:37 +00:00
},
2026-01-06 16:22:52 +02:00
addMediaPlaying(id) {
controlledOrUncontrolledSet(
this,
'mediaPlaying',
this.mediaPlaying.concat(id),
)
2020-09-29 10:18:37 +00:00
},
2026-01-06 16:22:52 +02:00
removeMediaPlaying(id) {
controlledOrUncontrolledSet(
this,
'mediaPlaying',
this.mediaPlaying.filter((mediaId) => mediaId !== id),
)
},
2026-01-06 16:22:52 +02:00
setHeadTailLinks(headTailLinks) {
this.headTailLinks = headTailLinks
2021-08-07 00:33:06 -04:00
},
2026-01-06 16:22:52 +02:00
toggleThreadDisplay() {
2021-08-07 00:33:06 -04:00
this.controlledToggleThreadDisplay()
2021-08-07 18:53:23 -04:00
},
2026-01-06 16:22:52 +02:00
scrollIfHighlighted(highlightId) {
2025-05-13 17:54:12 +03:00
if (this.$el.getBoundingClientRect == null) return
2021-08-07 18:53:23 -04:00
const id = highlightId
2017-04-12 19:07:55 +03:00
if (this.status.id === id) {
2022-07-31 12:35:48 +03:00
const rect = this.$el.getBoundingClientRect()
2017-04-12 19:07:55 +03:00
if (rect.top < 100) {
// Post is above screen, match its top to screen top
window.scrollBy(0, rect.top - 100)
2026-01-06 16:22:52 +02:00
} else if (rect.height >= window.innerHeight - 50) {
// Post we want to see is taller than screen so match its top to screen top
window.scrollBy(0, rect.top - 100)
} else if (rect.bottom > window.innerHeight - 50) {
// Post is below screen, match its bottom to screen bottom
window.scrollBy(0, rect.bottom - window.innerHeight + 50)
2017-04-12 19:07:55 +03:00
}
}
2023-07-13 00:37:57 -04:00
},
2026-01-06 16:22:52 +02:00
toggleDisplayQuote() {
2023-07-13 00:37:57 -04:00
if (this.shouldDisplayQuote) {
this.displayQuote = false
} else if (!this.quotedStatus) {
2026-01-06 16:22:52 +02:00
this.$store.dispatch('fetchStatus', this.status.quote_id).then(() => {
this.displayQuote = true
})
2023-07-13 00:37:57 -04:00
} else {
this.displayQuote = true
}
2026-01-06 16:22:52 +02:00
},
2021-08-07 18:53:23 -04:00
},
watch: {
2022-07-31 12:35:48 +03:00
highlight: function (id) {
2021-08-07 18:53:23 -04:00
this.scrollIfHighlighted(id)
},
'status.repeat_num': function (num) {
2019-06-27 08:19:35 -04:00
// refetch repeats when repeat_num is changed in any way
2026-01-06 16:22:52 +02:00
if (
this.isFocused &&
this.statusFromGlobalRepository.rebloggedBy &&
this.statusFromGlobalRepository.rebloggedBy.length !== num
) {
2019-06-27 08:14:54 -04:00
this.$store.dispatch('fetchRepeats', this.status.id)
}
},
'status.fave_num': function (num) {
2019-06-27 08:19:35 -04:00
// refetch favs when fave_num is changed in any way
2026-01-06 16:22:52 +02:00
if (
this.isFocused &&
this.statusFromGlobalRepository.favoritedBy &&
this.statusFromGlobalRepository.favoritedBy.length !== num
) {
2019-06-27 08:14:54 -04:00
this.$store.dispatch('fetchFavs', this.status.id)
}
2020-09-29 10:18:37 +00:00
},
2022-07-31 12:35:48 +03:00
isSuspendable: function (val) {
2020-09-29 10:18:37 +00:00
this.suspendable = val
2026-01-06 16:22:52 +02:00
},
},
2016-10-28 15:19:42 +02:00
}
export default Status