From 891fb0010781a9a5414a7e14c48af1e3d11495c4 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Sat, 7 Aug 2021 20:14:14 -0400 Subject: [PATCH] Add settings for max depth in thread --- src/components/conversation/conversation.js | 15 ++++++++++----- .../settings_modal/tabs/general_tab.vue | 13 +++++++++++++ src/modules/config.js | 3 ++- src/modules/instance.js | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 8e4eda51..853161df 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -74,7 +74,11 @@ const conversation = { }, computed: { maxDepthToShowByDefault () { - return 4 + // maxDepthInThread = max number of depths that is *visible* + // since our depth starts with 0 and "showing" means "showing children" + // there is a -2 here + const maxDepth = this.$store.getters.mergedConfig.maxDepthInThread - 2 + return maxDepth >= 1 ? maxDepth : 1 }, displayStyle () { return this.$store.getters.mergedConfig.conversationDisplay @@ -351,7 +355,8 @@ const conversation = { } this._diven = true const parentOrSelf = this.parentOrSelf(this.originalStatusId) - if (this.threadDisplayStatus[this.statusId] === 'hidden') { + // If current status is not visible + if (this.threadDisplayStatus[parentOrSelf] === 'hidden') { this.diveIntoStatus(parentOrSelf, /* preventScroll */ true) this.tryScrollTo(this.statusId) } @@ -429,7 +434,7 @@ const conversation = { toggleStatusContentProperty (id, name) { this.setStatusContentProperty(id, name, !this.statusContentProperties[id][name]) }, - leastShowingAncestor (id) { + leastVisibleAncestor (id) { let cur = id let parent = this.parentOf(cur) while (cur) { @@ -453,14 +458,14 @@ const conversation = { const oldHighlight = this.highlight this.diveHistory = [...this.diveHistory.slice(0, this.diveHistory.length - 1)] if (oldHighlight) { - this.tryScrollTo(this.leastShowingAncestor(oldHighlight)) + this.tryScrollTo(this.leastVisibleAncestor(oldHighlight)) } }, undive () { const oldHighlight = this.highlight this.diveHistory = [] if (oldHighlight) { - this.tryScrollTo(this.leastShowingAncestor(oldHighlight)) + this.tryScrollTo(this.leastVisibleAncestor(oldHighlight)) } else { this.goToCurrent() } diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue index 6d4c9249..536bfce3 100644 --- a/src/components/settings_modal/tabs/general_tab.vue +++ b/src/components/settings_modal/tabs/general_tab.vue @@ -87,6 +87,19 @@ {{ $t('settings.conversation_display') }} +
  • + + +
  • diff --git a/src/modules/config.js b/src/modules/config.js index 3a418bb6..44f73aae 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -72,7 +72,8 @@ export const defaultState = { hideUserStats: undefined, // instance default virtualScrolling: undefined, // instance default sensitiveByDefault: undefined, // instance default - conversationDisplay: undefined // instance default + conversationDisplay: undefined, // instance default + maxDepthInThread: 6 } // caching the instance default properties diff --git a/src/modules/instance.js b/src/modules/instance.js index 7cfd933f..4f024ca2 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -44,6 +44,7 @@ const defaultState = { virtualScrolling: true, sensitiveByDefault: false, conversationDisplay: 'simple_tree', + maxDepthInThread: 6, // Nasty stuff customEmoji: [],