diff --git a/changelog.d/virtual-scrolling-2.change b/changelog.d/virtual-scrolling-2.change deleted file mode 100644 index 74a47c6a9..000000000 --- a/changelog.d/virtual-scrolling-2.change +++ /dev/null @@ -1 +0,0 @@ -Implemented new virtual scrolling. Opening huge threads should be faster now diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 863e4f61e..1fed4c458 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -19,7 +19,6 @@ import { useConversation } from 'src/composables/useConversation.js' import { useScrollPosition } from 'src/composables/useScrollPosition.js' import { useTreeConversationTopology } from 'src/composables/useTreeConversationTopology.js' import { useVirtualScrolling } from 'src/composables/useVirtualScrolling.js' -import { useInterfaceSizes } from 'src/composables/useInterfaceSizes.js' import { WSConnectionStatus } from 'src/api/websocket.js' @@ -84,7 +83,7 @@ export default { } setFocused(id) const target = document.querySelector(`.Status[data-status-id=${id}]`) - return await scroller.scrollIntoView(target, { block: 'nearest' }) + return await scroller.scrollIntoView(target, { block: 'start' }) } const { statusId } = toRefs(props) @@ -133,7 +132,6 @@ export default { // # Main things const { currentStatus, - mainStatus, conversation, replies, getReplies, @@ -150,6 +148,7 @@ export default { resetDisplayState() } if (isPage.value) return + await tryScrollTo(currentStatus.value.id) }, { flush: 'post' }, ) @@ -188,37 +187,23 @@ export default { '-last': status.id === lastStatus.value?.id, }) - const { fontSize } = useInterfaceSizes() - - // Placeholder heights. - const mutedStatusHeight = computed(() => fontSize.value * 1.5) - const normalStatusHeight = computed(() => fontSize.value * 10) - const getPlaceholderHeight = (id) => - conversation.value.find((item) => item.id === id)?.muted - ? mutedStatusHeight - : normalStatusHeight - // # Linear style stuff const isLinearView = computed(() => displayStyle.value !== 'tree') const linearElement = useTemplateRef('linear') const linearScrollCompensation = computed( - () => isLinearView.value, + () => isLinearView.value && isExpanded.value, ) const { heightChart: heightChartLinear, changeSuspendState: changeSuspendStateLinear, updateVirtualHeight: updateVirtualHeightLinear, - pauseWatchers, - resumeWatchers, - } = useVirtualScrolling({ - list: conversation, - body: linearElement, - scrollPositionInstance: scroller, - scrollCompensation: linearScrollCompensation, - anchorId: mainStatus.value?.id, - anchorRepeatId: currentStatus.value?.id, - getPlaceholderHeight, - }) + } = useVirtualScrolling( + conversation, + linearElement, + scroller, + linearScrollCompensation, + currentStatus, + ) // # Tree style stuff const isTreeView = computed(() => displayStyle.value === 'tree') @@ -233,19 +218,18 @@ export default { const ancestorsElement = useTemplateRef('ancestors') const treeScrollCompensation = computed( - () => isTreeView.value, + () => isTreeView.value && isExpanded.value, ) const { heightChart: heightChartAncestors, changeSuspendState: changeSuspendStateAncestors, updateVirtualHeight: updateVirtualHeightAncestors, - } = useVirtualScrolling({ - list: currentAncestors, - body: ancestorsElement, - scrollPositionInstance: scroller, - scrollCompensation: treeScrollCompensation, - getPlaceholderHeight, - }) + } = useVirtualScrolling( + currentAncestors, + ancestorsElement, + scroller, + treeScrollCompensation, + ) const currentLevel = computed(() => [currentStatus.value].filter(Boolean)) const currentLevelElement = useTemplateRef('currentLevel') @@ -253,13 +237,7 @@ export default { heightChart: heightChartCurrentLevel, changeSuspendState: changeSuspendStateCurrentLevel, updateVirtualHeight: updateVirtualHeightCurrentLevel, - } = useVirtualScrolling({ - list: currentLevel, - body: currentLevelElement, - scrollPositionInstance: scroller, - scrollCompensation: false, - getPlaceholderHeight, - }) + } = useVirtualScrolling(currentLevel, currentLevelElement, scroller, false) const treeViewIsSimple = computed( () => !mergedConfig.value.conversationTreeAdvanced, diff --git a/src/components/conversation/conversation.vue b/src/components/conversation/conversation.vue index 8d4c4f967..3a61decf5 100644 --- a/src/components/conversation/conversation.vue +++ b/src/components/conversation/conversation.vue @@ -97,21 +97,19 @@ :class="{'thread-ancestor-has-other-replies': getReplies(element.id).size > 1, '-faded': shouldFadeAncestors}" > @@ -130,7 +128,7 @@