This commit is contained in:
Henry Jameson 2026-09-10 19:20:35 +03:00
commit 313a1758a5
4 changed files with 30 additions and 27 deletions

View file

@ -16,10 +16,10 @@ import { useStatusesStore } from 'src/stores/statuses.js'
import { useStreamingStore } from 'src/stores/streaming.js' import { useStreamingStore } from 'src/stores/streaming.js'
import { useConversation } from 'src/composables/useConversation.js' import { useConversation } from 'src/composables/useConversation.js'
import { useInterfaceSizes } from 'src/composables/useInterfaceSizes.js'
import { useScrollPosition } from 'src/composables/useScrollPosition.js' import { useScrollPosition } from 'src/composables/useScrollPosition.js'
import { useTreeConversationTopology } from 'src/composables/useTreeConversationTopology.js' import { useTreeConversationTopology } from 'src/composables/useTreeConversationTopology.js'
import { useVirtualScrolling } from 'src/composables/useVirtualScrolling.js' import { useVirtualScrolling } from 'src/composables/useVirtualScrolling.js'
import { useInterfaceSizes } from 'src/composables/useInterfaceSizes.js'
import { WSConnectionStatus } from 'src/api/websocket.js' import { WSConnectionStatus } from 'src/api/websocket.js'
@ -201,15 +201,11 @@ export default {
// # Linear style stuff // # Linear style stuff
const isLinearView = computed(() => displayStyle.value !== 'tree') const isLinearView = computed(() => displayStyle.value !== 'tree')
const linearElement = useTemplateRef('linear') const linearElement = useTemplateRef('linear')
const linearScrollCompensation = computed( const linearScrollCompensation = computed(() => isLinearView.value)
() => isLinearView.value,
)
const { const {
heightChart: heightChartLinear, heightChart: heightChartLinear,
changeSuspendState: changeSuspendStateLinear, changeSuspendState: changeSuspendStateLinear,
updateVirtualHeight: updateVirtualHeightLinear, updateVirtualHeight: updateVirtualHeightLinear,
pauseWatchers,
resumeWatchers,
} = useVirtualScrolling({ } = useVirtualScrolling({
list: conversation, list: conversation,
body: linearElement, body: linearElement,
@ -232,9 +228,7 @@ export default {
provide('threadDisplay', threadDisplay) provide('threadDisplay', threadDisplay)
const ancestorsElement = useTemplateRef('ancestors') const ancestorsElement = useTemplateRef('ancestors')
const treeScrollCompensation = computed( const treeScrollCompensation = computed(() => isTreeView.value)
() => isTreeView.value,
)
const { const {
heightChart: heightChartAncestors, heightChart: heightChartAncestors,
changeSuspendState: changeSuspendStateAncestors, changeSuspendState: changeSuspendStateAncestors,

View file

@ -22,7 +22,9 @@ export function useConversation(statusId, expanded) {
const loadError = ref(null) const loadError = ref(null)
const currentStatus = computed(() => getStatusObject(statusId.value)) const currentStatus = computed(() => getStatusObject(statusId.value))
const mainStatus = computed(() => currentStatus.value?.retweeted_status ?? currentStatus.value) const mainStatus = computed(
() => currentStatus.value?.retweeted_status ?? currentStatus.value,
)
const sortById = (a, b) => { const sortById = (a, b) => {
const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id

View file

@ -1,5 +1,5 @@
import { computed, ref, toValue, watch } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { computed, ref, watch } from 'vue'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
@ -20,17 +20,19 @@ export function useInterfaceSizes() {
watch(fontSizeSetting, updateFontSize, { immediate: true }) watch(fontSizeSetting, updateFontSize, { immediate: true })
const navbarSize = computed(() => { const navbarSize = computed(() => {
const string = fontSize.value * window const string =
.getComputedStyle(document.body) fontSize.value *
.getPropertyValue('--navbarSize') window.getComputedStyle(document.body).getPropertyValue('--navbarSize')
return fontSize.value * Number.parseInt(string.slice(0, -3), 10) // remove the 'rem' return fontSize.value * Number.parseInt(string.slice(0, -3), 10) // remove the 'rem'
}) })
const panelHeaderSize = computed(() => { const panelHeaderSize = computed(() => {
const string = fontSize.value * window const string =
.getComputedStyle(document.body) fontSize.value *
.getPropertyValue('--panelHeaderSize') window
.getComputedStyle(document.body)
.getPropertyValue('--panelHeaderSize')
return fontSize.value * Number.parseInt(string.slice(0, -3), 10) // remove the 'rem' return fontSize.value * Number.parseInt(string.slice(0, -3), 10) // remove the 'rem'
}) })

View file

@ -1,4 +1,4 @@
import { computed, ref, toValue, watch, nextTick } from 'vue' import { computed, nextTick, ref, toValue, watch } from 'vue'
import { useWindowSize } from 'src/composables/useWindowSize.js' import { useWindowSize } from 'src/composables/useWindowSize.js'
@ -63,11 +63,7 @@ export function useVirtualScrolling({
} }
// ## Scroll compensation // ## Scroll compensation
const { const { y: scrollY, scrollBy } = scrollPositionInstance
y: scrollY,
inProgress: scrollInProgress,
scrollBy,
} = scrollPositionInstance
watch(heightChart, async (newVal, oldVal) => { watch(heightChart, async (newVal, oldVal) => {
if (!toValue(scrollCompensation)) return if (!toValue(scrollCompensation)) return
if (newVal.length === 0 && oldVal.length === 0) return if (newVal.length === 0 && oldVal.length === 0) return
@ -76,7 +72,10 @@ export function useVirtualScrolling({
// If we're not given an achor, treat last element as one // If we're not given an achor, treat last element as one
const getAnchoredEl = (list) => const getAnchoredEl = (list) =>
toValue(anchorId) toValue(anchorId)
? list.find(({ id }) => id === toValue(anchorId) || id === toValue(anchorRepeatId)) ? list.find(
({ id }) =>
id === toValue(anchorId) || id === toValue(anchorRepeatId),
)
: list[list.length - 1] : list[list.length - 1]
const oldElement = getAnchoredEl(oldVal) const oldElement = getAnchoredEl(oldVal)
@ -85,8 +84,12 @@ export function useVirtualScrolling({
const diff = (() => { const diff = (() => {
if (oldElement && newElement) { if (oldElement && newElement) {
// Generic shifting // Generic shifting
const oldOffset = toValue(anchorId) ? oldElement.top : (oldElement.top + oldElement.height) const oldOffset = toValue(anchorId)
const newOffset = toValue(anchorId) ? newElement.top : (newElement.top + newElement.height) ? oldElement.top
: oldElement.top + oldElement.height
const newOffset = toValue(anchorId)
? newElement.top
: newElement.top + newElement.height
return newOffset - oldOffset return newOffset - oldOffset
} else if (!oldElement && newElement) { } else if (!oldElement && newElement) {
// Expansion // Expansion
@ -95,7 +98,9 @@ export function useVirtualScrolling({
// Collapsing // Collapsing
return 0 - oldElement.top - oldElement.height return 0 - oldElement.top - oldElement.height
} else { } else {
throw new Error("Somehow both new and old elements are missing, this shouldn't happen") throw new Error(
"Somehow both new and old elements are missing, this shouldn't happen",
)
} }
})() })()