fix: duplicated virtualizers
This commit is contained in:
1 parent
d950796ccd
commit
54f358649d
1 file changed
+5
-42
@@ -1,11 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import { buildCommentsTree } from '$lib/components/lemmy/comment/comments.js'
|
||||||
buildCommentsTree,
|
import { isImage } from '$lib/ui/image.js'
|
||||||
buildCommentsTreeAsync,
|
import { getClient } from '$lib/lemmy.js'
|
||||||
} from '$lib/components/lemmy/comment/comments.js'
|
|
||||||
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
|
||||||
import { isImage, isVideo } from '$lib/ui/image.js'
|
|
||||||
import { getClient, site } from '$lib/lemmy.js'
|
|
||||||
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
@@ -21,16 +17,8 @@
|
|||||||
PlusCircle,
|
PlusCircle,
|
||||||
ChatBubbleLeftRight,
|
ChatBubbleLeftRight,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
|
|
||||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
import {
|
import { Select, removeToast, toast } from 'mono-svelte'
|
||||||
Material,
|
|
||||||
Select,
|
|
||||||
Spinner,
|
|
||||||
buttonColor,
|
|
||||||
removeToast,
|
|
||||||
toast,
|
|
||||||
} from 'mono-svelte'
|
|
||||||
import type { CommentSortType } from 'lemmy-js-client'
|
import type { CommentSortType } from 'lemmy-js-client'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { instance } from '$lib/instance.js'
|
import { instance } from '$lib/instance.js'
|
||||||
@@ -39,19 +27,13 @@
|
|||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
import { feature } from '$lib/version.js'
|
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
||||||
import {
|
import { mediaType } from '$lib/components/lemmy/post/helpers.js'
|
||||||
bestImageURL,
|
|
||||||
mediaType,
|
|
||||||
optimizeImageURL,
|
|
||||||
} from '$lib/components/lemmy/post/helpers.js'
|
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
import { Popover } from 'mono-svelte'
|
import { Popover } from 'mono-svelte'
|
||||||
import { t } from '$lib/translations.js'
|
import { t } from '$lib/translations.js'
|
||||||
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
|
||||||
import { resumables } from '$lib/lemmy/item.js'
|
import { resumables } from '$lib/lemmy/item.js'
|
||||||
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
@@ -134,25 +116,6 @@
|
|||||||
|
|
||||||
$: remoteView =
|
$: remoteView =
|
||||||
$page.params.instance?.toLowerCase() != $instance.toLowerCase()
|
$page.params.instance?.toLowerCase() != $instance.toLowerCase()
|
||||||
|
|
||||||
const virtualizer = createWindowVirtualizer({
|
|
||||||
count: 0,
|
|
||||||
estimateSize: () => 50,
|
|
||||||
})
|
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
const comments = await data.comments
|
|
||||||
|
|
||||||
$virtualizer.setOptions({ count: comments.comments.length })
|
|
||||||
})
|
|
||||||
|
|
||||||
let virtualItemEls: HTMLElement[] = []
|
|
||||||
|
|
||||||
$: items = $virtualizer.getVirtualItems()
|
|
||||||
$: {
|
|
||||||
if (virtualItemEls.length)
|
|
||||||
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|||||||
Reference in new issue
Block a user