fix: reactivity for badges
This commit is contained in:
4 files changed
+26
-22
No files matched your search
@@ -47,21 +47,26 @@
|
|||||||
view?: View
|
view?: View
|
||||||
style?: string
|
style?: string
|
||||||
class?: ClassValue
|
class?: ClassValue
|
||||||
badges?: import('svelte').Snippet
|
extraBadges?: import('svelte').Snippet
|
||||||
onhide?: (hide: boolean) => void
|
onhide?: (hide: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
post,
|
post: passedPost = $bindable(),
|
||||||
actions = true,
|
actions = true,
|
||||||
hideCommunity = false,
|
hideCommunity = false,
|
||||||
view = settings.view,
|
view = settings.view,
|
||||||
style = '',
|
style = '',
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
badges,
|
extraBadges,
|
||||||
onhide,
|
onhide,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
|
let post = $state(passedPost)
|
||||||
|
$effect(() => {
|
||||||
|
passedPost = post
|
||||||
|
})
|
||||||
|
|
||||||
let tags = $derived(parseTags(post.post.name))
|
let tags = $derived(parseTags(post.post.name))
|
||||||
let type = $derived(mediaType(post.post.url, view))
|
let type = $derived(mediaType(post.post.url, view))
|
||||||
let rule = $derived(getTagRule(tags.tags))
|
let rule = $derived(getTagRule(tags.tags))
|
||||||
@@ -76,6 +81,17 @@
|
|||||||
post.post.embed_description == post.post.body &&
|
post.post.embed_description == post.post.body &&
|
||||||
view != 'compact',
|
view != 'compact',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let badges = $derived({
|
||||||
|
deleted: post.post.deleted,
|
||||||
|
removed: post.post.removed,
|
||||||
|
locked: post.post.locked,
|
||||||
|
featured: post.post.featured_local || post.post.featured_community,
|
||||||
|
nsfw: post.post.nsfw || post.community.nsfw,
|
||||||
|
saved: post.saved,
|
||||||
|
admin: post.creator_is_admin,
|
||||||
|
moderator: post.creator_is_moderator,
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -110,16 +126,7 @@
|
|||||||
showCommunity={!hideCommunity}
|
showCommunity={!hideCommunity}
|
||||||
user={post.creator}
|
user={post.creator}
|
||||||
published={publishedToDate(post.post.published)}
|
published={publishedToDate(post.post.published)}
|
||||||
badges={{
|
{badges}
|
||||||
deleted: post.post.deleted,
|
|
||||||
removed: post.post.removed,
|
|
||||||
locked: post.post.locked,
|
|
||||||
featured: post.post.featured_local || post.post.featured_community,
|
|
||||||
nsfw: post.post.nsfw || post.community.nsfw,
|
|
||||||
saved: post.saved,
|
|
||||||
admin: post.creator_is_admin,
|
|
||||||
moderator: post.creator_is_moderator,
|
|
||||||
}}
|
|
||||||
subscribed={profile.data?.user?.follows
|
subscribed={profile.data?.user?.follows
|
||||||
.map((c) => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(post.community.id)
|
.includes(post.community.id)
|
||||||
@@ -132,13 +139,10 @@
|
|||||||
edited={post.post.updated}
|
edited={post.post.updated}
|
||||||
tags={tags?.tags}
|
tags={tags?.tags}
|
||||||
{view}
|
{view}
|
||||||
>
|
{extraBadges}
|
||||||
{#snippet extraBadges()}
|
/>
|
||||||
{@render badges?.()}
|
|
||||||
{/snippet}
|
|
||||||
</PostMeta>
|
|
||||||
{#key post.post.url}
|
{#key post.post.url}
|
||||||
<div style="grid-area:embed;" class={view == 'compact' ? '' : 'contents'}>
|
<div style="grid-area:embed;" class={{ contents: view == 'cozy' }}>
|
||||||
{#if rule != 'hide'}
|
{#if rule != 'hide'}
|
||||||
<PostMedia
|
<PostMedia
|
||||||
post={post.post}
|
post={post.post}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
url={community?.icon}
|
url={community?.icon}
|
||||||
width={view == 'compact' ? 24 : 32}
|
width={view == 'compact' ? 24 : 32}
|
||||||
alt={community?.name}
|
alt={community?.name}
|
||||||
class="row-span-2 flex-shrink-0 mr-2"
|
class="row-span-2 flex-shrink-0 mr-2 self-center"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if showCommunity && community}
|
{#if showCommunity && community}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
posts = posts.toSpliced(index, 1)
|
posts = posts.toSpliced(index, 1)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#snippet badges()}
|
{#snippet extraBadges()}
|
||||||
{#if post.withCrossposts}
|
{#if post.withCrossposts}
|
||||||
<button
|
<button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
|
|||||||
@@ -234,13 +234,13 @@
|
|||||||
: ''} -mx-4 sm:-mx-6 px-4 sm:px-6"
|
: ''} -mx-4 sm:-mx-6 px-4 sm:px-6"
|
||||||
>
|
>
|
||||||
<Post
|
<Post
|
||||||
|
bind:post={posts[row.index]}
|
||||||
hideCommunity={community}
|
hideCommunity={community}
|
||||||
view={(posts[row.index]?.post.featured_community ||
|
view={(posts[row.index]?.post.featured_community ||
|
||||||
posts[row.index]?.post.featured_local) &&
|
posts[row.index]?.post.featured_local) &&
|
||||||
settings.posts.compactFeatured
|
settings.posts.compactFeatured
|
||||||
? 'compact'
|
? 'compact'
|
||||||
: settings.view}
|
: settings.view}
|
||||||
{post}
|
|
||||||
class="transition-all duration-250"
|
class="transition-all duration-250"
|
||||||
onhide={() => {
|
onhide={() => {
|
||||||
posts = posts.toSpliced(row.index, 1)
|
posts = posts.toSpliced(row.index, 1)
|
||||||
|
|||||||
Reference in new issue
Block a user