From 2b272ee2499185bf701fc4a237c55326c116a2f8 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 8 Sep 2026 17:44:16 +0300 Subject: [PATCH] restored virtual scrolling things --- src/components/conversation/conversation.js | 33 +++++++++++++++++++- src/components/conversation/conversation.vue | 6 ++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 92c93eade..bbb55cd04 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,6 +1,15 @@ import { get } from 'lodash-es' import { storeToRefs } from 'pinia' -import { computed, nextTick, provide, ref, toRefs, watch } from 'vue' +import { + computed, + nextTick, + onMounted, + provide, + ref, + toRefs, + useTemplateRef, + watch, +} from 'vue' import { useRouter } from 'vue-router' import ChatMessageList from 'src/components/chat_message_list/chat_message_list.vue' @@ -251,7 +260,12 @@ export default { } // # Virtual scrolling stuff + const body = useTemplateRef('body') const { virtualHidden } = toRefs(props) + const virtualHeight = ref(120) + const hiddenStyle = computed(() => ({ + height: this.virtualHeight + 'px', + })) const unsuspendibleIds = ref(new Set()) const suspendable = computed(() => unsuspendibleIds.value.size === 0) const hide = computed(() => virtualHidden.value && suspendable.value) @@ -262,6 +276,21 @@ export default { unsuspendibleIds.value.delete(id) } } + const updateVirtualHeight = () => { + if (hide) return // no updates when not rendering + if (!status.value) return // not loaded yet + nextTick(() => { + virtualHeight.value = body.value.getBoundingClientRect().height + emit('update:virtualHeight', { + id: status.value.id, + height: virtualHeight.value, + top: body.value.clientTop, + }) + }) + } + onMounted(() => { + updateVirtualHeight() + }) // # Misc UI things const firstStatus = computed(() => conversation.value[0]) @@ -437,7 +466,9 @@ export default { // # Virtual scrolling stuff hide, onStatusSuspendStateChange, + updateVirtualHeight, virtualHidden, + hiddenStyle, // # Misc UI things getStatusClasses, diff --git a/src/components/conversation/conversation.vue b/src/components/conversation/conversation.vue index 03bcfef86..cebb9a10d 100644 --- a/src/components/conversation/conversation.vue +++ b/src/components/conversation/conversation.vue @@ -1,6 +1,7 @@