diff --git a/src/components/status/status.js b/src/components/status/status.js
index 814b3e3c8..8ad8d684b 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -96,7 +96,7 @@ const Status = {
props: {
statusId: String,
statusoid: Object,
- replies: Array,
+ replies: Set,
expandable: Boolean,
focused: Boolean,
@@ -109,12 +109,11 @@ const Status = {
inQuote: Boolean,
profileUserId: String,
- simpleTree: Boolean,
showOtherRepliesAsButton: Boolean,
canDive: Boolean,
ignoreMute: Boolean,
- threadDisplayStatus: String,
+ threadDisplayState: String,
},
emits: [
'goto',
@@ -166,6 +165,9 @@ const Status = {
user() {
return useUsersStore().findUser(this.mainStatus.user.id)
},
+ simpleTree() {
+ return !this.mergedConfig.conversationTreeAdvanced
+ },
showReasonMutedThread() {
return (
(this.mainStatus.thread_muted || this.repeatStatus?.thread_muted) &&
@@ -436,10 +438,10 @@ const Status = {
return !this.replying && this.mediaPlaying.size === 0
},
inThreadForest() {
- return !!this.threadDisplayStatus
+ return !!this.threadDisplayState
},
threadShowing() {
- return this.threadDisplayStatus === 'showing'
+ return this.threadDisplayState === 'showing'
},
visibilityLocalized() {
return this.$i18n.t('general.scope_in_timeline.' + this.status.visibility)
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index db303daae..4322c6033 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -180,7 +180,7 @@
diff --git a/src/components/status_action_buttons/buttons_definitions.js b/src/components/status_action_buttons/buttons_definitions.js
index 762b5be6a..1fc6c8ae9 100644
--- a/src/components/status_action_buttons/buttons_definitions.js
+++ b/src/components/status_action_buttons/buttons_definitions.js
@@ -234,7 +234,7 @@ export const BUTTONS = [
return chatView
},
action({ router, status }) {
- router.push({ name: 'conversation', params: { id: status.id } })
+ router.push({ name: 'conversation', params: { statusId: status.id } })
},
},
{
@@ -293,7 +293,7 @@ export const BUTTONS = [
navigator.clipboard.writeText(
[
useInstanceStore().server,
- router.resolve({ name: 'conversation', params: { id: status.id } })
+ router.resolve({ name: 'conversation', params: { statusId: status.id } })
.href,
].join(''),
)
diff --git a/src/components/thread_tree/thread_tree.js b/src/components/thread_tree/thread_tree.js
index 6bcfa469f..1c3b3560a 100644
--- a/src/components/thread_tree/thread_tree.js
+++ b/src/components/thread_tree/thread_tree.js
@@ -4,41 +4,95 @@ import {
faAngleDoubleRight,
} from '@fortawesome/free-solid-svg-icons'
+import { useMergedConfigStore } from 'src/stores/merged_config.js'
+
library.add(faAngleDoubleDown, faAngleDoubleRight)
const ThreadTree = {
components: {},
name: 'ThreadTree',
props: {
- depth: Number,
statusId: String,
inProfile: Boolean,
- conversation: Array,
collapsable: Boolean,
isExpanded: Boolean,
pinnedStatusIdsObject: Object,
profileUserId: String,
+ depth: Number,
+ conversation: Array,
focused: String,
- getReplies: Function,
- toggleExpanded: Function,
+ replies: Map,
- simple: Boolean,
canDive: Boolean,
- threadDisplayStatus: Object,
- showThreadRecursively: Function,
- totalReplyCount: Object,
- totalReplyDepth: Object,
+ threadDisplay: Map,
+ threadDisplayDefault: Map,
},
- emits: ['suspendableStateChange', 'goto', 'dive', 'heightChange'],
+ emits: [
+ 'suspendableStateChange',
+ 'goto',
+ 'dive',
+ 'heightChange',
+ 'toggleExpanded',
+ 'showThreadRecursively',
+ ],
computed: {
currentReplies() {
- return this.getReplies(this.statusId).map(({ id }) => id)
+ return [...this.getReplies(this.statusId)].map(({ id }) => id)
+ },
+ simple() {
+ return !useMergedConfigStore().mergedConfig.conversationTreeAdvanced
},
threadShowing() {
- return this.threadDisplayStatus[this.statusId] === 'showing'
+ const result = this.threadDisplay.get(this.statusId) ?? this.threadDisplayDefault.get(this.statusId)
+ return result === 'showing'
+ },
+ totalReplyCount() {
+ const sizes = {}
+ const subTreeSizeFor = (id) => {
+ if (sizes[id]) {
+ return sizes[id]
+ }
+ sizes[id] =
+ 1 +
+ [...this.getReplies(id)]
+ .map(({ id }) => id)
+ .map((cid) => subTreeSizeFor(cid))
+ .reduce((a, b) => a + b, 0)
+ return sizes[id]
+ }
+ this.conversation.map((k) => k.id).forEach(subTreeSizeFor)
+ return Object.keys(sizes).reduce((res, id) => {
+ res[id] = sizes[id] - 1 // exclude itself
+ return res
+ }, {})
+ },
+ totalReplyDepth() {
+ const depths = {}
+ const subTreeDepthFor = (id) => {
+ if (depths[id]) {
+ return depths[id]
+ }
+ depths[id] =
+ 1 +
+ [...this.getReplies(id)]
+ .map(({ id }) => id)
+ .map((cid) => subTreeDepthFor(cid))
+ .reduce((a, b) => (a > b ? a : b), 0)
+ return depths[id]
+ }
+ this.conversation.map((k) => k.id).forEach(subTreeDepthFor)
+ return Object.keys(depths).reduce((res, id) => {
+ res[id] = depths[id] - 1 // exclude itself
+ return res
+ }, {})
},
},
+ methods: {
+ getReplies(id) {
+ return this.replies.get(id) ?? new Set()
+ },
+ }
}
export default ThreadTree
diff --git a/src/components/thread_tree/thread_tree.vue b/src/components/thread_tree/thread_tree.vue
index d7ae9cd10..3d21daa8d 100644
--- a/src/components/thread_tree/thread_tree.vue
+++ b/src/components/thread_tree/thread_tree.vue
@@ -14,15 +14,14 @@
:profile-user-id="profileUserId"
class="conversation-status conversation-status-treeview panel-body"
- :simple-tree="simple"
- :thread-display-status="threadDisplayStatus[statusId]"
+ :thread-display-state="threadDisplay.get(statusId)"
:can-dive="canDive"
@dive="$emit('dive', statusId)"
@goto="$emit('goto', statusId)"
- @toggle-expanded="toggleExpanded"
- @suspendable-state-change="e => $emit('suspendableStateChange', e)"
- @height-change="e => $emit('heightChange', e)"
+ @toggle-expanded="$emit('toggleExpanded', statusId)"
+ @suspendable-state-change="$emit('suspendableStateChange', e)"
+ @height-change="$emit('heightChange', e)"
/>
$emit('showThreadRecursively', e)"
@goto="(e) => $emit('goto', e)"
@dive="(e) => $emit('dive', e)"
@suspendable-state-change="e => $emit('suspendableStateChange', e)"
+ @toggle-expanded="(e) => $emit('toggleExpanded', e)"
@height-change="e => $emit('heightChange', e)"
/>
@@ -88,7 +85,7 @@
tag="button"
keypath="status.thread_show_full_with_icon"
class="button-unstyled -link thread-tree-show-replies-button"
- @click.prevent="showThreadRecursively(statusId)"
+ @click.prevent="$emit('showThreadRecursively', statusId)"
>