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

64 lines
1.4 KiB
JavaScript
Raw Normal View History

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 = {
2026-06-04 21:59:09 +03:00
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,
2026-06-30 06:00:41 +03:00
canDive: Boolean,
2021-08-07 00:33:06 -04:00
threadDisplayStatus: Object,
showThreadRecursively: Function,
totalReplyCount: Object,
2021-08-07 10:28:45 -04:00
totalReplyDepth: Object,
2021-08-06 20:18:27 -04:00
},
2026-06-30 06:00:41 +03:00
emits: ['suspendableStateChange', 'dive'],
2021-08-06 20:18:27 -04:00
computed: {
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
},
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 16:22:52 +02:00
},
2021-08-06 20:18:27 -04:00
}
export default ThreadTree