fix: PostFeed.svelte not updating
This commit is contained in:
5 files changed
+40
-85
No files matched your search
@@ -5,9 +5,6 @@
|
||||
import type { PostView } from 'lemmy-js-client'
|
||||
import { Badge, Button } from 'mono-svelte'
|
||||
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
import { combineCrossposts } from './crosspost.svelte'
|
||||
|
||||
interface Props {
|
||||
posts: PostView[]
|
||||
@@ -24,11 +21,6 @@
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props()
|
||||
let etc = rest
|
||||
|
||||
let combinedPosts = $derived(combineCrossposts(posts))
|
||||
|
||||
let viewPost: number = $state(-1)
|
||||
</script>
|
||||
|
||||
<ul
|
||||
@@ -50,67 +42,21 @@
|
||||
</Placeholder>
|
||||
</div>
|
||||
{:else}
|
||||
{#each combinedPosts as post, index}
|
||||
{#if !(settings.hidePosts.deleted && post.post.deleted) && !(settings.hidePosts.removed && post.post.removed)}
|
||||
<li class="relative post-container">
|
||||
<Post
|
||||
hideCommunity={community}
|
||||
view={(post.post.featured_community || post.post.featured_local) &&
|
||||
settings.posts.compactFeatured
|
||||
? 'compact'
|
||||
: settings.view}
|
||||
{post}
|
||||
class="transition-all duration-250"
|
||||
onhide={() => {
|
||||
posts = posts.toSpliced(index, 1)
|
||||
}}
|
||||
>
|
||||
{#snippet extraBadges()}
|
||||
{#if post.withCrossposts}
|
||||
<button
|
||||
onclick={() => {
|
||||
if (viewPost == post.post.id) viewPost = -1
|
||||
else viewPost = post.post.id
|
||||
}}
|
||||
>
|
||||
<Badge
|
||||
class="z-10 backdrop-blur-xl hover:brightness-110 cursor-pointer transition-all"
|
||||
color="gray-subtle"
|
||||
>
|
||||
{#if viewPost == post.post.id}
|
||||
<Icon mini src={Minus} size="14" />
|
||||
{:else}
|
||||
<Icon mini src={Plus} size="14" />
|
||||
{/if}
|
||||
{post.crossposts.length} crosspost{post.crossposts.length ==
|
||||
1
|
||||
? ''
|
||||
: 's'}
|
||||
</Badge>
|
||||
</button>{/if}
|
||||
{/snippet}
|
||||
</Post>
|
||||
{#if post.withCrossposts && viewPost == post.post.id}
|
||||
<div
|
||||
transition:slide|global={{
|
||||
axis: 'y',
|
||||
duration: 500,
|
||||
easing: expoOut,
|
||||
}}
|
||||
>
|
||||
<span class="text-sm flex flex-row gap-2 items-center">
|
||||
Crossposts <hr class="w-full dark:border-zinc-800" />
|
||||
{post.crossposts.length}
|
||||
</span>
|
||||
{#each post.crossposts as crosspost, index}
|
||||
<div class="w-full transition-all mb-4">
|
||||
<Post post={crosspost} view={settings.view} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</li>
|
||||
{/if}
|
||||
{#each posts as post, index (post.post.id)}
|
||||
<li class="relative post-container">
|
||||
<Post
|
||||
hideCommunity={community}
|
||||
view={(post.post.featured_community || post.post.featured_local) &&
|
||||
settings.posts.compactFeatured
|
||||
? 'compact'
|
||||
: settings.view}
|
||||
{post}
|
||||
class="transition-all duration-250"
|
||||
onhide={() => {
|
||||
posts = posts.toSpliced(index, 1)
|
||||
}}
|
||||
/>
|
||||
</li>
|
||||
{/each}
|
||||
{/if}
|
||||
{@render children?.()}
|
||||
|
||||
Reference in new issue
Block a user