fixes, cleanup, now properly renders ancestors etc

This commit is contained in:
Henry Jameson 2026-09-09 15:37:29 +03:00
commit ed7a1e70e8
4 changed files with 36 additions and 28 deletions

View file

@ -103,13 +103,6 @@ export default {
const toggleExpanded = () => { const toggleExpanded = () => {
expanded.value = !expanded.value expanded.value = !expanded.value
} }
watch(expanded, (value) => {
if (value) {
fetchConversation()
} else {
resetDisplayState()
}
})
provide('isExpanded', isExpanded) provide('isExpanded', isExpanded)
provide('isPage', isPage) provide('isPage', isPage)
@ -139,6 +132,14 @@ export default {
loadError, loadError,
} = useConversation(focusedId, isExpanded) } = useConversation(focusedId, isExpanded)
watch(expanded, (value) => {
if (value) {
fetchConversation()
} else {
resetDisplayState()
}
})
const resetDisplayState = () => { const resetDisplayState = () => {
setFocused(statusId.value) setFocused(statusId.value)
resetThreadDisplay() resetThreadDisplay()
@ -175,12 +176,12 @@ export default {
// # Linear style stuff // # Linear style stuff
const isLinearView = computed(() => displayStyle.value !== 'tree') const isLinearView = computed(() => displayStyle.value !== 'tree')
const body = useTemplateRef('body') const linearElement = useTemplateRef('linear')
const { const {
heightChart: heightChartLinear, heightChart: heightChartLinear,
changeSuspendState: changeSuspendStateLinear, changeSuspendState: changeSuspendStateLinear,
updateVirtualHeight: updateVirtualHeightLinear, updateVirtualHeight: updateVirtualHeightLinear,
} = useVirtualScrolling(conversation, body) } = useVirtualScrolling(conversation, linearElement)
// # Tree style stuff // # Tree style stuff
const isTreeView = computed(() => displayStyle.value === 'tree') const isTreeView = computed(() => displayStyle.value === 'tree')
@ -200,7 +201,7 @@ export default {
updateVirtualHeight: updateVirtualHeightAncestors, updateVirtualHeight: updateVirtualHeightAncestors,
} = useVirtualScrolling(currentAncestors, ancestorsElement) } = useVirtualScrolling(currentAncestors, ancestorsElement)
const currentLevel = computed(() => [currentStatus.value]) const currentLevel = computed(() => [currentStatus.value].filter(Boolean))
const currentLevelElement = useTemplateRef('currentLevel') const currentLevelElement = useTemplateRef('currentLevel')
const { const {
heightChart: heightChartCurrentLevel, heightChart: heightChartCurrentLevel,
@ -215,7 +216,7 @@ export default {
() => currentAncestors.value.length > 0 && topLevel.value.length > 1, () => currentAncestors.value.length > 0 && topLevel.value.length > 1,
) )
const shouldShowAncestors = computed( const shouldShowAncestors = computed(
() => isExpanded.value && currentAncestors.value.size > 0, () => isExpanded.value && heightChartAncestors.value.length > 0,
) )
const shouldFadeAncestors = computed( const shouldFadeAncestors = computed(
() => mergedConfig.value.conversationTreeFadeAncestors, () => mergedConfig.value.conversationTreeFadeAncestors,

View file

@ -37,7 +37,7 @@
/> />
</div> </div>
<div <div
v-if="isPage && !status" v-if="isPage && !currentStatus"
class="conversation-body" class="conversation-body"
ref="body" ref="body"
:class="{ 'panel-body': isExpanded }" :class="{ 'panel-body': isExpanded }"
@ -92,25 +92,31 @@
class="thread-ancestors" class="thread-ancestors"
> >
<article <article
v-for="status in currentAncestors" v-for="element in heightChartAncestors"
class="thread-ancestor" class="thread-ancestor"
:class="{'thread-ancestor-has-other-replies': statusReplies.size > 1, '-faded': shouldFadeAncestors}" :class="{'thread-ancestor-has-other-replies': getReplies(element.id).size > 1, '-faded': shouldFadeAncestors}"
> >
<Status <Status
v-if="element.type === 'status'"
class="conversation-status panel-body" class="conversation-status panel-body"
:class="getStatusClasses(status)" :class="getStatusClasses(element.status)"
:status-id="status.id" :status-id="element.status.id"
:replies="getReplies(status.id)" :replies="getReplies(element.status.id)"
:focused="focused === status.id" :focused="focused === element.status.id"
can-dive can-dive
@goto="setFocused" @goto="setFocused"
@dive="diveIntoStatus(status.id)" @dive="diveIntoStatus(element.status.id)"
@suspendable-state-change="changeSuspendStateAncestors" @suspendable-state-change="changeSuspendStateAncestors"
@height-change="updateVirtualHeightAncestors" @height-change="updateVirtualHeightAncestors"
/> />
<div
v-if="element.type === 'spacer'"
class="virtual-spacer"
:style="{ height: element.height + 'px' }"
/>
<div <div
v-if="shouldShowOtherRepliesButton && getReplies(status.id).size > 1" v-if="shouldShowOtherRepliesButton && getReplies(status.id).size > 1"
class="thread-ancestor-dive-box" class="thread-ancestor-dive-box"
@ -141,7 +147,7 @@
</article> </article>
</div> </div>
<div <div
class="currentStatus" class="currentLevel"
ref="currentLevel" ref="currentLevel"
> >
<!-- Technically this will always have a single element but --> <!-- Technically this will always have a single element but -->
@ -169,6 +175,7 @@
</div> </div>
<div <div
v-else-if="isLinearView" v-else-if="isLinearView"
ref="linear"
class="thread-body" class="thread-body"
> >
<article <article
@ -176,11 +183,6 @@
class="panel-body" class="panel-body"
:key="element.id ?? element.ids" :key="element.id ?? element.ids"
> >
<div
v-if="element.type === 'spacer'"
class="virtual-spacer"
:style="{ height: element.height + 'px' }"
/>
<Status <Status
v-if="element.type === 'status'" v-if="element.type === 'status'"
class="conversation-status" class="conversation-status"
@ -195,6 +197,11 @@
@suspendable-state-change="changeSuspendStateLinear" @suspendable-state-change="changeSuspendStateLinear"
@height-change="updateVirtualHeightLinear" @height-change="updateVirtualHeightLinear"
/> />
<div
v-if="element.type === 'spacer'"
class="virtual-spacer"
:style="{ height: element.height + 'px' }"
/>
</article> </article>
</div> </div>
</div> </div>

View file

@ -81,7 +81,7 @@ export function useTreeConversationTopology(conversation, replies, current) {
}) })
const threadDisplay = computed(() => { const threadDisplay = computed(() => {
return new Map( return new Map(
[...threadDisplayOverride.value.entries()].map(([k, v]) => [ [...threadDisplayDefault.value.entries()].map(([k, v]) => [
k, k,
threadDisplayOverride.value.get(k) ?? threadDisplayDefault.value.get(k), threadDisplayOverride.value.get(k) ?? threadDisplayDefault.value.get(k),
]), ]),

View file

@ -1,5 +1,5 @@
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { computed, onMounted, ref, watch } from 'vue' import { computed, ref, watch } from 'vue'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useStatusesStore } from 'src/stores/statuses.js' import { useStatusesStore } from 'src/stores/statuses.js'
@ -82,7 +82,7 @@ export function useVirtualScrolling(conversation, body) {
watch(windowHeight, updateBoundaries) watch(windowHeight, updateBoundaries)
watch(scrollY, updateBoundaries) watch(scrollY, updateBoundaries)
watch(totalHeight, updateBoundaries) watch(totalHeight, updateBoundaries)
onMounted(updateBoundaries) watch(body, updateBoundaries)
const heightChart = computed(() => { const heightChart = computed(() => {
// Map every height and suspendable state // Map every height and suspendable state