restored virtual scrolling things
This commit is contained in:
parent
5971c5bb79
commit
2b272ee249
2 changed files with 36 additions and 3 deletions
|
|
@ -1,6 +1,15 @@
|
||||||
import { get } from 'lodash-es'
|
import { get } from 'lodash-es'
|
||||||
import { storeToRefs } from 'pinia'
|
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 { useRouter } from 'vue-router'
|
||||||
|
|
||||||
import ChatMessageList from 'src/components/chat_message_list/chat_message_list.vue'
|
import ChatMessageList from 'src/components/chat_message_list/chat_message_list.vue'
|
||||||
|
|
@ -251,7 +260,12 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// # Virtual scrolling stuff
|
// # Virtual scrolling stuff
|
||||||
|
const body = useTemplateRef('body')
|
||||||
const { virtualHidden } = toRefs(props)
|
const { virtualHidden } = toRefs(props)
|
||||||
|
const virtualHeight = ref(120)
|
||||||
|
const hiddenStyle = computed(() => ({
|
||||||
|
height: this.virtualHeight + 'px',
|
||||||
|
}))
|
||||||
const unsuspendibleIds = ref(new Set())
|
const unsuspendibleIds = ref(new Set())
|
||||||
const suspendable = computed(() => unsuspendibleIds.value.size === 0)
|
const suspendable = computed(() => unsuspendibleIds.value.size === 0)
|
||||||
const hide = computed(() => virtualHidden.value && suspendable.value)
|
const hide = computed(() => virtualHidden.value && suspendable.value)
|
||||||
|
|
@ -262,6 +276,21 @@ export default {
|
||||||
unsuspendibleIds.value.delete(id)
|
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
|
// # Misc UI things
|
||||||
const firstStatus = computed(() => conversation.value[0])
|
const firstStatus = computed(() => conversation.value[0])
|
||||||
|
|
@ -437,7 +466,9 @@ export default {
|
||||||
// # Virtual scrolling stuff
|
// # Virtual scrolling stuff
|
||||||
hide,
|
hide,
|
||||||
onStatusSuspendStateChange,
|
onStatusSuspendStateChange,
|
||||||
|
updateVirtualHeight,
|
||||||
virtualHidden,
|
virtualHidden,
|
||||||
|
hiddenStyle,
|
||||||
|
|
||||||
// # Misc UI things
|
// # Misc UI things
|
||||||
getStatusClasses,
|
getStatusClasses,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
v-if="!hide"
|
v-if="!hide"
|
||||||
|
ref="body"
|
||||||
class="Conversation"
|
class="Conversation"
|
||||||
:class="{ '-expanded' : isExpanded, '-page': isPage, 'panel' : isExpanded }"
|
:class="{ '-expanded' : isExpanded, '-page': isPage, 'panel' : isExpanded }"
|
||||||
>
|
>
|
||||||
|
|
@ -39,7 +40,6 @@
|
||||||
<div
|
<div
|
||||||
v-if="isPage && !status"
|
v-if="isPage && !status"
|
||||||
class="conversation-body"
|
class="conversation-body"
|
||||||
ref="body"
|
|
||||||
:class="{ 'panel-body': isExpanded }"
|
:class="{ 'panel-body': isExpanded }"
|
||||||
>
|
>
|
||||||
<p v-if="!loadStatusError">
|
<p v-if="!loadStatusError">
|
||||||
|
|
@ -56,7 +56,6 @@
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
class="conversation-body"
|
class="conversation-body"
|
||||||
ref="body"
|
|
||||||
:class="{ 'panel-body': isExpanded }"
|
:class="{ 'panel-body': isExpanded }"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
@ -108,6 +107,7 @@
|
||||||
@goto="setFocused"
|
@goto="setFocused"
|
||||||
@dive="diveIntoStatus(status.id)"
|
@dive="diveIntoStatus(status.id)"
|
||||||
@suspendable-state-change="onStatusSuspendStateChange"
|
@suspendable-state-change="onStatusSuspendStateChange"
|
||||||
|
@height-change="updateVirtualHeight"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="shouldShowOtherRepliesButton && statusReplies.size > 1"
|
v-if="shouldShowOtherRepliesButton && statusReplies.size > 1"
|
||||||
|
|
@ -147,6 +147,7 @@
|
||||||
@toggle-expanded="toggleExpanded"
|
@toggle-expanded="toggleExpanded"
|
||||||
@show-thread-recursively="showThreadRecursively"
|
@show-thread-recursively="showThreadRecursively"
|
||||||
@suspendable-state-change="onStatusSuspendStateChange"
|
@suspendable-state-change="onStatusSuspendStateChange"
|
||||||
|
@height-change="updateVirtualHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
@ -169,6 +170,7 @@
|
||||||
@goto="setFocused"
|
@goto="setFocused"
|
||||||
@toggle-expanded="toggleExpanded"
|
@toggle-expanded="toggleExpanded"
|
||||||
@suspendable-state-change="onStatusSuspendStateChange"
|
@suspendable-state-change="onStatusSuspendStateChange"
|
||||||
|
@height-change="updateVirtualHeight"
|
||||||
/>
|
/>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue