diff --git a/src/lib/app/render/VirtualList.svelte b/src/lib/app/render/VirtualList.svelte index dd25280d..fdad90af 100644 --- a/src/lib/app/render/VirtualList.svelte +++ b/src/lib/app/render/VirtualList.svelte @@ -139,38 +139,38 @@ } function resizeObserver(node: HTMLElement) { - const debouncedUpdate = debounce((entries: ResizeObserverEntry[]) => { - for (const entry of entries) { - const indexAttr = node.getAttribute('data-index') - if (indexAttr === null) continue - const index = Number(indexAttr) - if (isNaN(index)) continue - - const newHeight = entry.contentRect.height - if (itemHeights[index] !== newHeight) { - itemHeights[index] = newHeight - if (!initialRender) visibleItems = updateVisibleItems() - } - } - }, debounceResize) - - const observer = new ResizeObserver((entries) => { - debouncedUpdate(entries) - }) - observer.observe(node) - onDestroy(() => { - observer.disconnect() - }) - return { destroy() { - observer.disconnect() + observer.unobserve(node) }, } } + const debouncedUpdate = debounce((entries: ResizeObserverEntry[]) => { + for (const entry of entries) { + const indexAttr = entry.target.getAttribute('data-index') + if (indexAttr === null) continue + const index = Number(indexAttr) + if (isNaN(index)) continue + + const newHeight = entry.contentRect.height + if (itemHeights[index] !== newHeight) { + itemHeights[index] = newHeight + if (!initialRender) visibleItems = updateVisibleItems() + } + } + }, debounceResize) + + const observer = new ResizeObserver((entries) => { + debouncedUpdate(entries) + }) + + onDestroy(() => { + observer.disconnect() + }) + // Scroll position changes (only every few px) let oldScroll = $state(0) $effect(() => { @@ -196,6 +196,7 @@ itemHeights[index] = newHeight } }) + untrack(() => { visibleItems = updateVisibleItems() initialRender = false diff --git a/src/lib/feature/post/feed/VirtualFeed.svelte b/src/lib/feature/post/feed/VirtualFeed.svelte index 92e69019..c27cfb01 100644 --- a/src/lib/feature/post/feed/VirtualFeed.svelte +++ b/src/lib/feature/post/feed/VirtualFeed.svelte @@ -2,12 +2,13 @@ import { browser } from '$app/environment' import { client } from '$lib/api/client.svelte' import type { GetPosts, PostView } from '$lib/api/types' + import { errorMessage } from '$lib/app/error' import { t } from '$lib/app/i18n' import VirtualList from '$lib/app/render/VirtualList.svelte' import { settings } from '$lib/app/settings.svelte' import Placeholder from '$lib/ui/info/Placeholder.svelte' import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte' - import { Button } from 'mono-svelte' + import { Button, Material, Spinner } from 'mono-svelte' import { onDestroy, onMount, untrack } from 'svelte' import { ArchiveBox, @@ -213,15 +214,16 @@ {#if settings.infiniteScroll && browser && posts.length > 0} {#if error} -
-
- + +
+ + {errorMessage(error)}
-
{error}
-
+ {:else if hasMore} -
-
-
-
-
-
-
+
+
{:else}
{$t('routes.frontpage.endFeed', { - community_name: params.community_name ?? 'undefined', + community_name: + params.community_name ?? + 'Lemmy. There are no more posts. You saw them all.', })} {#snippet action()}
{/if} - + {/if} {@render children?.()} diff --git a/src/lib/ui/info/ErrorContainer.svelte b/src/lib/ui/info/ErrorContainer.svelte index f7648428..91aa222a 100644 --- a/src/lib/ui/info/ErrorContainer.svelte +++ b/src/lib/ui/info/ErrorContainer.svelte @@ -16,7 +16,7 @@