Merge branch 'main' into auth-impr

This commit is contained in:
Xylight authored and GitHub committed 2025-07-12 11:41:05 -07:00
commit 0430838666
9 files changed
+72 -81

No files matched your search

+1 -6
View File
@@ -68,11 +68,6 @@
view != 'compact' &&
type != 'iframe',
)
let hideBody = $derived(
settings.posts.deduplicateEmbed &&
post.post.embed_description == post.post.body &&
view != 'compact',
)
let badges = $derived({
deleted: post.post.deleted,
@@ -154,7 +149,7 @@
/>
{/if}
{/key}
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody && rule != 'hide'}
{#if post.post.body && !post.post.nsfw && view != 'compact'}
<PostBody
element="section"
body={post.post.body}
@@ -112,11 +112,11 @@
{style}
>
<PostVote
bind:post={post.post}
vote={post.my_vote}
score={post.counts.score}
upvotes={post.counts.upvotes}
downvotes={post.counts.downvotes}
post={post.post}
bind:vote={post.my_vote}
bind:score={post.counts.score}
bind:upvotes={post.counts.upvotes}
bind:downvotes={post.counts.downvotes}
showCounts={profile.current?.user?.local_user_view?.local_user
?.show_scores ?? true}
/>
@@ -35,15 +35,15 @@
upvotes?: number
downvotes?: number
showCounts?: boolean
children?: import('svelte').Snippet<[{ vote: number; score: number }]>
children?: import('svelte').Snippet<[{ vote?: number; score?: number }]>
}
let {
post = $bindable(),
vote = $bindable(0),
vote = $bindable(),
score = $bindable(),
upvotes = $bindable(0),
downvotes = $bindable(0),
upvotes = $bindable(),
downvotes = $bindable(),
showCounts = true,
children,
}: Props = $props()
@@ -99,7 +99,7 @@
out:fly={{ duration: 400, y: 10, easing: backOut }}
aria-label={$t('aria.vote.upvotes', { default: upvotes })}
>
<FormattedNumber number={upvotes} />
<FormattedNumber number={upvotes ?? 0} />
</span>
{/key}
</span>
@@ -127,7 +127,7 @@
out:fly={{ duration: 400, y: 10, easing: backOut }}
aria-label={$t('aria.vote.downvotes', { default: downvotes })}
>
<FormattedNumber number={downvotes} />
<FormattedNumber number={downvotes ?? 0} />
</span>
{/key}
</span>
@@ -50,6 +50,7 @@
let hasMore = $state(true)
async function loadMore() {
console.log(hasMore, loading)
if (!hasMore || loading) return
try {
@@ -255,7 +256,14 @@
</EndPlaceholder>
</div>
{/if}
<InfiniteScroll window threshold={1000} on:loadMore={loadMore} />
<InfiniteScroll
window
threshold={600}
on:loadMore={() => {
console.log('loadMore triggered')
loadMore()
}}
/>
{/if}
{@render children?.()}
</ul>
+28 -11
View File
@@ -1,7 +1,7 @@
<script lang="ts" generics="T">
import { browser } from '$app/environment'
import { debounce } from 'mono-svelte/util/time'
import { onDestroy, untrack, type Snippet } from 'svelte'
import { onDestroy, onMount, untrack, type Snippet } from 'svelte'
import type { HTMLAttributes } from 'svelte/elements'
import { innerHeight } from 'svelte/reactivity/window'
@@ -72,15 +72,6 @@
let viewportHeight = $state(0)
let visibleItems = $state<{ index: number; offset: number }[]>([])
// Initial render
$effect.pre(() => {
if (virtualListEl && browser) {
untrack(() => {
visibleItems = updateVisibleItems()
})
}
})
$effect.pre(() => {
if (items.length > itemHeights.length) {
const missing = items.length - itemHeights.length
@@ -88,6 +79,14 @@
}
})
$effect(() => {
if (items.length) {
untrack(() => {
visibleItems = updateVisibleItems()
})
}
})
function findFirstVisibleIndex(
scrollTop: number,
cumulativeHeights: number[],
@@ -146,7 +145,6 @@
const newHeight = entry.contentRect.height
if (itemHeights[index] !== newHeight) {
itemHeights[index] = newHeight
visibleItems = updateVisibleItems()
}
}
}, debounceResize)
@@ -179,6 +177,25 @@
})
}
})
onMount(() => {
if (virtualListEl && browser) {
Array.from(virtualListEl.children).forEach(node => {
const indexAttr = node.getAttribute('data-index')
if (indexAttr === null) return
const index = Number(indexAttr)
if (isNaN(index)) return
const newHeight = node.getBoundingClientRect().height
if (itemHeights[index] !== newHeight) {
itemHeights[index] = newHeight
}
})
untrack(() => {
visibleItems = updateVisibleItems()
})
}
})
</script>
<svelte:window