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

102 lines
2.3 KiB
JavaScript
Raw Normal View History

2026-01-08 17:26:52 +02:00
2021-08-07 18:53:23 -04:00
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faAngleDoubleDown,
2026-01-06 16:22:52 +02:00
faAngleDoubleRight,
2021-08-07 18:53:23 -04:00
} from '@fortawesome/free-solid-svg-icons'
2026-01-06 16:22:52 +02:00
library.add(faAngleDoubleDown, faAngleDoubleRight)
2021-08-07 18:53:23 -04:00
2021-08-06 20:18:27 -04:00
const ThreadTree = {
components: {
2021-08-06 20:18:27 -04:00
},
name: 'ThreadTree',
props: {
depth: Number,
status: Object,
inProfile: Boolean,
conversation: Array,
collapsable: Boolean,
isExpanded: Boolean,
pinnedStatusIdsObject: Object,
profileUserId: String,
2025-05-13 17:54:35 +03:00
isFocusedFunction: Function,
2021-08-07 18:53:23 -04:00
highlight: String,
2021-08-06 20:18:27 -04:00
getReplies: Function,
setHighlight: Function,
2021-08-07 00:33:06 -04:00
toggleExpanded: Function,
2021-08-07 18:53:23 -04:00
simple: Boolean,
2021-08-07 00:33:06 -04:00
// to control display of the whole thread forest
toggleThreadDisplay: Function,
threadDisplayStatus: Object,
showThreadRecursively: Function,
totalReplyCount: Object,
2021-08-07 10:28:45 -04:00
totalReplyDepth: Object,
statusContentProperties: Object,
setStatusContentProperty: Function,
toggleStatusContentProperty: Function,
2026-01-06 16:22:52 +02:00
dive: Function,
2021-08-06 20:18:27 -04:00
},
computed: {
2026-01-06 16:22:52 +02:00
suspendable() {
const selfSuspendable = this.$refs.statusComponent
? this.$refs.statusComponent.suspendable
: true
if (this.$refs.childComponent) {
2026-01-06 16:22:52 +02:00
return (
selfSuspendable &&
this.$refs.childComponent.every((s) => s.suspendable)
)
}
return selfSuspendable
},
2026-01-06 16:22:52 +02:00
reverseLookupTable() {
2026-01-06 17:32:22 +02:00
return this.conversation.reduce(
(table, status, index) => {
table[status.id] = index
return table
},
{
/* no-op */
},
)
2021-08-06 20:18:27 -04:00
},
2026-01-06 16:22:52 +02:00
currentReplies() {
return this.getReplies(this.status.id).map(({ id }) =>
this.statusById(id),
)
2021-08-06 20:18:27 -04:00
},
2026-01-06 16:22:52 +02:00
threadShowing() {
2021-08-07 00:33:06 -04:00
return this.threadDisplayStatus[this.status.id] === 'showing'
2021-08-07 10:28:45 -04:00
},
2026-01-06 16:22:52 +02:00
currentProp() {
2021-08-07 10:28:45 -04:00
return this.statusContentProperties[this.status.id]
2026-01-06 16:22:52 +02:00
},
2021-08-06 20:18:27 -04:00
},
methods: {
2026-01-06 16:22:52 +02:00
statusById(id) {
2021-08-06 20:18:27 -04:00
return this.conversation[this.reverseLookupTable[id]]
},
2026-01-06 17:32:22 +02:00
collapseThread() {
/* no-op */
},
showThread() {
/* no-op */
},
showAllSubthreads() {
/* no-op */
},
2026-01-06 16:22:52 +02:00
toggleCurrentProp(name) {
2021-08-07 10:28:45 -04:00
this.toggleStatusContentProperty(this.status.id, name)
},
2026-01-06 16:22:52 +02:00
setCurrentProp(name) {
this.setStatusContentProperty(this.status.id, name)
2026-01-06 16:22:52 +02:00
},
},
2021-08-06 20:18:27 -04:00
}
export default ThreadTree