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

88 lines
2.1 KiB
JavaScript
Raw Normal View History

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